🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Wait for a CreateProcess spawned application to terminate...

#12885
From: Remy Lebeau (TeamB)
Date: Wed, 12 Nov 2003 02:22
26 lines
2099 bytes
"Conny H�kansson" <conny@allimac.se> wrote in message
news:3fb19517@newsgroups.borland.com...

> I was loo�king in the PROCESS_INFORMATION structure,
> but im not sure i f i can use any of those for checking the lifetmie
> of the process that is spawned. I guess that the Handles and
> ProcessIds will remain the value

That is exactly what you need to use.  Pass the returned process handle (not
the thread handle) to WaitForSingleObject().  When the process terminates,
its handle will be signalled, thus releasing WaitForSingleObject() from its
waiting.  If you are doing this in the context of the main thread, and you
have an GUI available, then you should call WaitForSingleObject() in a loop
so that you can call Application->ProcessMessages() periodically to keep the
GUI responsive.

> and jsut become invalid as far as the OS is concerned. So
> checking them for a zero value would be meaningless, right???

No.  If CreateProcess() succeeds, then they will contains valid values.
Make sure that you pass the returned handles to CloseHandle() when you are
done with them.


Gambit
Technical Details
Message-ID: <3fb198a7$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.he.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3fb19517@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,aeafaa878f9b7ab6
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-11 18:21:45 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3fb19517@newsgroups.borland.com>
Subject: Re: Wait for a CreateProcess spawned application to terminate...
Date: Tue, 11 Nov 2003 18:22:45 -0800
Lines: 28
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.137.149
Message-ID: <3fb198a7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1068603559 67.22.137.149 (11 Nov 2003 18:19:19 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.he.net!news-hog.berkeley.edu!ucberkeley!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail