Solved

CreateProcess??

Posted on 1998-07-29
6
202 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 100 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why would downloading El capitan OSX update be troublesome e.g timeout many many times?? 11 579
C++ Language error 28 218
Best book to learn C++ 4 79
Safe conversion? 4 68
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  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 …
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

778 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