🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to run a Command in a progam and wait until finish?

#1248
From: Michel Leunen
Date: Sun, 23 Sep 2007 19:04
32 lines
1934 bytes
Phuoc wrote:
> I tried to google "ShellExecute wait" there are many different solutions 
> suggested. They all look a bit complicated. Is there another command for 
> this and can pause the main process?

Don't use ShellExecute() for this but CreateProcess() along with 
WaitForSingleObject().
Something like this:

    PROCESS_INFORMATION piProcInfo;
    STARTUPINFO siStartInfo;

    memset(&siStartInfo, NULL, sizeof(STARTUPINFO));
    siStartInfo.cb = sizeof(STARTUPINFO);
    //launch your application
    CreateProcess(NULL, "yourApp.exe",
                  NULL, NULL, 0, 0, NULL, NULL,
                  &siStartInfo, &piProcInfo);

    //Wait for your application to end
    WaitForSingleObject(piProcInfo.hProcess,INFINITE);
    ...

HTH
Michel

-- 
----------------------------------------
Michel Leunen
http://www.leunen.com/

----------------------------------------
Technical Details
Message-ID: <46f6b8c3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <op.ty303qdoewlac1@centrino>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,b7bfc196b0d38789
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Sun, 23 Sep 2007 21:04:36 +0200
From: Michel Leunen <nospam@noreply.be>
Organization: www.leunen.com
User-Agent: Thunderbird 2.0.0.6 (Windows/20070728)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: How to run a Command in a progam and wait until finish?
References: <op.ty303qdoewlac1@centrino>
In-Reply-To: <op.ty303qdoewlac1@centrino>
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 87.67.123.91
Message-ID: <46f6b8c3$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1190574275 87.67.123.91 (23 Sep 2007 12:04:35 -0700)
Lines: 32
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail