Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Newbie: CreateProcess problem

Status
Not open for further replies.

Baal80

Programmer
Aug 14, 2004
14
PL
Hello, I have a following problem. My app starts an external app (code is shown below), and waits for it to finish. That's OK but sometimes this external app launches *its* child app and terminates itself. How can I determine if this "child-app" (launched by external app) had finished execution? Particularly, I launch a deinstaller but this deinstaller launches a main deinstaller and terminates - my program doesn't wait for the main deinstaller to finish - I'd like to know if it's possible.
ANY help would be greatly appreciated, as I've searched the net for a solution and found nothing :(

My sample code for launching external app looks like this:

STARTUPINFO StartInfo;
PROCESS_INFORMATION ProcInfo;
memset(&ProcInfo, 0, sizeof(ProcInfo));
memset(&StartInfo, 0 , sizeof(StartInfo));
StartInfo.cb = sizeof(StartInfo);

if (FileExists(deinstaller.c_str())==true)
{
int res = CreateProcess(deinstaller.c_str(), params.c_str(), NULL, NULL, NULL, NULL, NULL, NULL, &StartInfo, &ProcInfo);

if (res)
{
WaitForSingleObject(ProcInfo.hThread, INFINITE);
CloseHandle(ProcInfo.hProcess);
}
}
 
The quickest way just to check if a window is open is to use the Windows API FindWindow function. This works but looking at all open windows and comparing their titles to one specified by you. MSDN should explain how to use it.

Hope that helps,
ROn

cout << "If you don't know where you want to go, we'll make sure you get taken";
 
Well, I'm not sure you've understood my problem (or maybe I didn't present it clear enough). The first app I launch is unknown to me, I only know its path. This app launches another app, that I know virtually *nothing* about - even its name. So I can't use FindWindow as I don't know the second application window's name :(

I'm starting to doubt if there's ANY possible solution to this problem - I tried on several forums and nobody was able to give me the proper answer :(
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top