|
-
June 1st, 2010, 03:55 PM
#1
Running AND tracking other executables from C++
So I've got some code that I'm writing that I want to call another .exe file. I don't have access to the source of that .exe and there is no dll form of it so I'm stuck with what I've got. So I want to make a call to run that code (which I do know how to do).
But I need the code I'm writing to wait for the other executable to be done running before it continues (and unfortunately there's a LOT of variation in its run time). Is there any ways to use API calls to cause some sort of wait loop to wait for another executable to be done?
-
June 1st, 2010, 04:06 PM
#2
Re: Running AND tracking other executables from C++
Use ShellExecuteEx with SHELLEXECUTEINFO set to return the handle to the running app, then wait on that handle:
Code:
SHELLEXECUTEINFO sei;
memset(&sei,0,sizeof(SHELLEXECUTEINFO));
sei.cbSize=sizeof(SHELLEXECUTEINFO);
sei.fMask=SEE_MASK_NOCLOSEPROCESS;
sei.lpVerb=L"OPEN";
sei.lpFile=L"C:\\Program Files (x86)\\MyProgram\\MyProgram.exe";
sei.lpDirectory=L"C:\\Program Files (x86)\\MyProgram\\";
sei.nShow=1;
ShellExecuteEx(&sei);
WaitForSingleObject(sei.hProcess,INFINITE);
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|