Solved

CreateProcess??

Posted on 1998-07-29
6
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: 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

Industry Leaders: 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!

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

717 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