PDA

View Full Version : AppUpdate in Delphi (AppMenu)



jon.andri
05-22-2002, 06:39 AM
I am testing this UpdateService for the first time.

I am adding code behind my menu in Delphi. I am using the AppUpdate command after I have created a Agent variable.

My question is, where does this AppMenu, EndInstall & AppStart parameters come from? Where can I find them or what do I have to include?


My code -

pAgent := CreateOleObject('DWUpdateService.Agent');
pAgent.AppUpdate(C_PGUID, AppMenu);

(AppMenu here is not known)

Jan_Cieslicki
05-22-2002, 07:26 AM
This is what I have done in Delphi ver. 5.0.


uses

.............,DWUSWebAgentLib_TLB,
DWUpdateServiceLib_TLB;

private
{ Private declarations }
Check_For_Updates : IAgent;


procedure TEmuDemo.mnu_ChkUpdtClick(Sender: TObject);
begin
Check_For_Updates:=CoAgent.Create;
if Check_For_Updates.IsConnected then
begin
Check_For_Updates.DisplayMessages('{GUID number here}');
end;

and it appears to work.

Regards

Jan

Chris Woerner
05-22-2002, 11:53 AM
just fyi.....

When we first started testing the Update Service, we had a series of functions...

IsConnected
HasMessages
DisplayMessages
GetMessages
AutoUpdate

etc....

We found the most common implementation of those functions and created AppUpdate. As a result, you can often create the same behavior that AppUpdate demonstrates using the individual functions.

For example, AppUpdate() with an arguement of AppMenu is the same as...

IsConnected
if connected, DisplayMessages()
if not connected, error message

You can see the flow chart for how AppUpdate behaves by looking in the help and doing an index search on AppUpdate.

jon.andri
05-22-2002, 12:40 PM
I have imported the Type Library for the InstallShield UpdateService and created IAgent variable like Jan mentioned.

Then I have an easy access to all the methods that Chris was talking about and I am just experimenting with different ways to do this.

Thanks a lot guys ;)

Jan_Cieslicki
05-23-2002, 07:03 AM
Jon,

I'll be interested in your experience with AppUpdate in Delphi.

I wasn't very successful, so any example of source code using the above would be appreciated. Jan

jon.andri
05-23-2002, 09:18 AM
After I imported the type library (DWUpdateServiceLib_TLB) I had no problem with this. For those who need it, select Project -> Import type library - then click add and point to the Agent.exe file.

When that is done I add DWUpdateServiceLib_TLB to the uses clause in my form. Then I have a UpdateMe procedure I can call whereever I need. This procedure is below (C_PGUID is a constant with my product GUID)

procedure TForm1.UpdateMe;
var
pAgent :IAgent;
begin
pAgent := CoAgent.Create;
if pAgent.IsConnected then
pAgent.DisplayMessages(C_PGUID);
end;

I also tried another version of it:

procedure TForm1.UpdateMe;
var
pAgent :IAgent;
begin
pAgent := CoAgent.Create;
if pAgent.IsConnected then
if not pAgent.AutoUpdate(C_PGUID, false, 0, 0) then
ShowMessage('No updates available');
end;

which gives you a different update process.
Also like Chris pointed out, you can experiment with different combinations of those commands.