[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

HINSTANCe ShellExecute

Posted on 1997-12-15
3
Medium Priority
?
669 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 400 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

Industry Leaders: 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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

649 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