Solved

HINSTANCe ShellExecute

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 134
repeatSeparator  java  challenge 13 58
Complete beginner needs help making a cron job 9 129
I could not set window to top 4 40
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: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

763 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