Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

CreateProcess??

Posted on 1998-07-29
6
Medium Priority
?
211 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

618 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