Solved

HINSTANCe ShellExecute

Posted on 1997-12-15
3
639 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Adapt this command to show who installed 29 106
Separate files macro - Errors on larger data set 18 65
Hibernate methods 2 68
Unix Command -- Challenging  question 7 87
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

911 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

19 Experts available now in Live!

Get 1:1 Help Now