Solved

CreateProcess??

Posted on 1998-07-29
6
197 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
Comment Utility
Edited text of question
0
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
Comment Utility
answer coming.
0
 
LVL 22

Expert Comment

by:nietod
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Yinteo
Comment Utility
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
Comment Utility
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
Comment Utility
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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now