Article View: borland.public.cppbuilder.nativeapi
Article #5790Re: SendMessage() repetition error
From: Remy Lebeau (TeamB)
Date: Fri, 01 Jul 2005 01:40
Date: Fri, 01 Jul 2005 01:40
48 lines
2583 bytes
2583 bytes
"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message
news:42c49e3e$1@newsgroups.borland.com...
> An easier, and more reliable, way is to use WaitForSingleObject() instead.
> CreateProcess() returns the HANDLE for the newly spawned process. You
> can pass that HANDLE to WaitForSingleObject(), which will not return until
> the process has terminated.
For example:
bool __fastcall RunProgram(const AnsiString &FileName, const AnsiString
&Params, bool WaitUntilExit = true)
{
AnsiString CmdLine;
if( Params.IsEmpty() )
CmdLine = FileName;
else
CmdLine = (AnsiQuotedStr(FileName) + " " + Params);
STARTUPINFO si = {sizeof(STARTUPINFO), 0};
PROCESS_INFORMATION pi = {0};
// fill in si as needed...
if( CreateProcess(FileName.c_str(), CmdLine.c_str(), NULL, NULL,
FALSE, 0, NULL, NULL, &si, &pi) )
{
if( WaitUntilExit )
WaitForSingleObject(pi.hProcess, INFINITE);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
return true;
}
return false;
}
{
if( RunProgram("c:\\path\\Bubba.exe", "first set of parameters") )
RunProgram("c:\\path\\Bubba.exe", "second set of parameters");
}
Gambit
Technical Details
Message-ID:
<42c4a2f3$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsfeed.gamma.ru!Gamma.RU!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!213.239.142.2.MISMATCH!feeder.xsnews.nl!feeder1.cambrium.nl!feed.tweaknews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.netcologne.de!newsfeed-fusi.netcologne.de!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42c49259@newsgroups.borland.com> <42c49e3e$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,696995b85f90e7d7 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <42c49259@newsgroups.borland.com> <42c49e3e$1@newsgroups.borland.com> Subject: Re: SendMessage() repetition error Date: Thu, 30 Jun 2005 18:40:15 -0700 Lines: 50 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 NNTP-Posting-Host: 68.69.17.41 Message-ID: <42c4a2f3$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1120183027 68.69.17.41 (30 Jun 2005 18:57:07 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsfeed.gamma.ru!Gamma.RU!news-out2.kabelfoon.nl!newsfeed.kabelfoon.nl!bandi.nntp.kabelfoon.nl!213.239.142.2.MISMATCH!feeder.xsnews.nl!feeder1.cambrium.nl!feed.tweaknews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!news.netcologne.de!newsfeed-fusi.netcologne.de!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail