🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #9342

Re: Program Update...

#9342
From: Bob Gonder
Date: Sat, 17 Jul 2004 05:48
25 lines
2034 bytes
Shane Stump wrote:

>I am in the process of writing a component for my applications that check /
>download a new version of the program. The actual file that is downloaded is
>a setup program. Can anyone recommend the BEST way to shutdown my current
>running application and launch the downloaded the Setup.exe?

Well, it would seem like using CreateProcess on Setup.exe, then
immediately terminating would do the job.
But there is a race condition. Not so significant if Setup needs to
unpack before it installs....but still...

One way is for the application to use 	GetCurrentProcessId(), convert
the ID to a string and pass that as a parameter to Setup.

If Setup doesn't see the parameter, then it was manually started, so
just go ahead and install.
If Setup sees the parameter, it waits for the caller to close:

ProcessID = atol(argv[1]);
OldProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, ProcessID);
if( OldProcess != NULL )
{	WaitForSingleObject(OldProcess, INFINITE);
	CloseHandle(OldProcess);
}
Technical Details
Message-ID: <jqehf0d0r75u75ueq75mmlfd6fauqc4ula@4ax.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!62.253.162.219.MISMATCH!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <40f84e2c$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,7b54786b87ab9c42
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Program Update...
Date: Fri, 16 Jul 2004 22:48:01 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <jqehf0d0r75u75ueq75mmlfd6fauqc4ula@4ax.com>
References: <40f84e2c$1@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 65.41.125.111
X-Trace: newsgroups.borland.com 1090043277 65.41.125.111 (16 Jul 2004 22:47:57 -0700)
Lines: 27
Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!proxad.net!62.253.162.219.MISMATCH!news-out.ntli.net!newsrout1.ntli.net!news-in.ntli.net!ntli.net!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail