shell programming

Igops88
Igops88 used Ask the Experts™
on
GOOD DAY!

Would like to ask for help!

I wrote a VC++ application, that runs multiple applications, and I used the ShellExecute() to run each application. How would I determine if the first application is already done in processing or already terminated so that I can proceed in executing the next application and so on.

If I'll going to check the process ID, how would it be?, or is there any other way of executing application rather than ShellExecute(), to meet my requirements?

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
for processes:

BOOL GetExitCodeProcess(
  HANDLE hProcess,
  LPDWORD lpExitCode
);

--if the process hasn't terminated lpExitCode is STILL_ACTIVE

--The handle must have the PROCESS_QUERY_INFORMATION access right. security descriptors are changable with SetSecurityInfo()

Commented:
I'll assume (lacking any information from you) that you're starting your new processes with CreateProcess() or ShellExecuteEx().

Either of these (but NOT ShellExecute) will give you a HANDLE to the newly created process.  Using this handle you can check on the status of the process and even have your app wait on it (or them) with WaitForSingleObject() or WaitForMultipleObjects().

Commented:
This question didn't show any activity for more than 21 days. I will ask Community Support to close it unless you finalize it yourself within 7 days.
You can always request to keep this question open. But remember, experts can only help if you provide feedback to their comments.
Unless there is objection or further activity,  I will suggest to accept

    "jennyy"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
========
Werner
Force accepted

** Mindphaser - Community Support Moderator **

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial