Solved

HINSTANCe ShellExecute

Posted on 1997-12-15
3
637 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
Comment Utility
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
Comment Utility
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
Comment Utility
// 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

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

Join & Write a Comment

Suggested Solutions

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
This video discusses moving either the default database or any database to a new volume.

771 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

10 Experts available now in Live!

Get 1:1 Help Now