?
Solved

CreateProcess??

Posted on 1998-07-29
6
Medium Priority
?
213 Views
Last Modified: 2012-05-05
Hi,
I have a question here: Below is part of my codes:

bRetVal = CreateProcess(NULL,"c:\\application\\setup.exe", NULL,NULL,FALSE,NORMAL_PRIORITY_CLASS,NULL,NULL,&StartupInfo,&ProcessInformation);
do
{      GetExitCodeProcess(ProcessInformation.hProcess,lpExitCode);
}while(*lpExitCode==STILL_ACTIVE)

I use CreateProcess() to run the setup of a particular application. However when I use the GetExitCodeProcess to determine whether the application setup  has terminated.

 I discovered that the GetexitCodeProcess returns that the process has terminated (although the setup process is still runing).  Then I found out that this is because the setup process generated other processes to continue the application setup and then terminated itself.

My question is how can my calling process determine that the application setup has terminated.

Thanks.
0
Comment
Question by:Yinteo
  • 3
  • 2
6 Comments
 

Author Comment

by:Yinteo
ID: 1169008
Edited text of question
0
 
LVL 22

Accepted Solution

by:
nietod earned 200 total points
ID: 1169009
answer coming.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1169010
I think the problem is in your last paramater to GetExitCodeProcess().  In this parameter you are supposed to pass a pointer to a DWORD that you want set to the exit code.  You must have a particular DWORD that you want Windows to sent, in other words you should do

DWORD ExitCode;
GetExitCodeProcess(ProcessInformation.hProcess,&ExitCode);

and it will set ExitCode.  If you do

LPDWORD lpExitCode;
GetExitCodeProcess(ProcessInformation.hProcess,lpExitCode);

then lpExitCode is a pointer that could point just about anywhere.  Windows will use this pointer to store a value and will probably cause problems.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Yinteo
ID: 1169011
Hi,

I tired to replace lpExitCode with &ExitCode... the GetExitCodeProcess function still returns that the setup process has terminated. This is indeed true the setup process terminated.
But it created 2 other processes before it terminated. This 2 other processes continues the application setup. Thus I was not  able to determine when my application setup ended.

How can I determine that my application setup completed although the setup process(which is recorded in the CreateProcess()'s process information structure) terminated?  
0
 
LVL 11

Expert Comment

by:alexo
ID: 1169012
A "busy wait" is the worst thing you can do on a multitasking platform!

What you want to do is:

    if (WaitForSingleObject(ProcessInformation->hProcess, INFINITE) != WAIT_OBJECT_0)
    {
        // Display an error.  Use GetLastError() to get the error code.
    }

0
 
LVL 22

Expert Comment

by:nietod
ID: 1169013
Agreed, but that still doesn't solve the problem.  
are their "results" of the setup that you can look for?  like files placed in certain locations, new registery entries etc...
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question