Solved

HINSTANCe ShellExecute

Posted on 1997-12-15
3
644 Views
Last Modified: 2013-11-19
When i start a Shell Command to run an installer (like a Setup.Exe from my C/C++ MFC Programm through SheelExecute() API Fonction), How could i know when the Executable i ran is over , or is still running , for the good continuation of my programm ?

Thx , and cya

http://model.tekno.org
0
Comment
Question by:SkizoWalker
3 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1312357
You really can't. The only way to do so is to use CreateProcess instead. CreateProcess returns a process by which you can use WaitForSingleObject() on the handle to know when the process has terminated.
0
 

Author Comment

by:SkizoWalker
ID: 1312358
Can ytou gimem da code i have to use ? you will earn 150 points at all !!! Let's try ur luck !

0
 
LVL 7

Accepted Solution

by:
galkin earned 100 total points
ID: 1312359
// strCmdLine is command line

STARTUPINFO StartupInfo;
PROCESS_INFORMATION ProcessInformation;

::ZeroMemory(&StartupInfo, sizeof(StartupInfo));
StartupInfo.cb = sizeof(StartupInfo);

::ZeroMemory(&ProcessInformation, sizeof(ProcessInformation));

            if(::CreateProcess( NULL,
                          (LPTSTR)(LPCTSTR)strCmdLine,
                          NULL,
                          NULL,
                          TRUE,
                          CREATE_DEFAULT_ERROR_MODE,
                          NULL,
                          NULL,
                          &StartupInfo,
                          &ProcessInformation
                        )
              )
{
::WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
// WaitForSingleObject exits when process terminates
::CloseHandle(ProcessInformation.hProcess);
::CloseHandle(ProcessInformation.hThread);
}



            

0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 129
conditional code and condition difference 9 82
child constructor and parent constructor, overriding and overloading 6 84
Capture logon name 13 73
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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