PDA

View Full Version : Running Update Service on Application Start



PaulCardamone
04-21-2002, 11:59 PM
What is the simplest way to run the agent from Visual C++?

Thanks

Mark at IS
04-22-2002, 08:12 AM
To check for and display update messages when your application is launched, use the Agent executable's -au command line option; this performs the recommended series of operations for that scenario. For example:

Agent -au{C4091E43-4FC0-11D5-8C6C-00104B9747FA} -AppStart

For details, see the SDK help.

PaulCardamone
04-22-2002, 06:09 PM
Does anyone have any sample c++ code to do this?

Thanks

Sunny's
04-22-2002, 07:28 PM
If you do not already have installed InstallShield Update Service SDK, Download and Install it from http://saturn.installshield.com/isus/sdk/InstallShieldUpdateServiceSDK.exe.

There are 2 ways to invoke AppUpdate() as follows:

1. Go to the UpdateService Help as follows:
a) From Start Menu, select InstallShield then click on UpdateService Help
b) From Contents tab. open node 'Advanced Use'.
c) Now open nodes, Tell Me About -> Agent object model -> Agent Object
d) Select AppUpdate in particular and click on Visual C++ link to see sample code required to use AppUpdate in action.

2. Agent.exe can also be invoked as an Exe as follows:

Please consult Update Service Help again and search for 'Command line Options'.
Here you will be able to find various command line options provided by agent.exe.One in particular interested is "<agentpath\agent.exe>-au<product code> -<event>"
Construct strCommandLine in example below and use it as follows:

STARTUPINFO si = {0};
si.cb = sizeof(STARTUPINFO);
is::AUTO_PROCESS_INFORMATION pi;

//Construct strCommandLine here. Sample command line is
//c:\program files\common files\UpdateService\Agent.exe -au{C4091E43-4FC0-11D5-8C6C-00104B9747FA} -AppStart

if (!::CreateProcess(NULL, strCommandLine, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi))
{
DWORD dwErr = ::GetLastError();
ATLTRACE("\nCreateProcess returned %i\n", dwErr);
char sbuff[1024];
::sprintf(sbuff, "Unable to invoke Agent.exe - %s", strCommandLine);
::MessageBox (0, sbuff, "Update Error", MB_ICONERROR | MB_OK);
}