Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding out when an application is closed

Status
Not open for further replies.

CMR

Programmer
Apr 30, 2002
76
AU
I have an application that starts other applications using ShellExecute (it's a simple menu system). My question is: is there any way my menu app can know when the application it has executed is closed?

thanks in advance

CMR
 
Call ShellExecuteEx instead of ShellExecute.
Include SEE_MASK_NOCLOSEPROCESS in the fMask field of the SHELLEXECUTEINFO structure. After a successfull call of ShellExecuteEx, the hProcess field of SHELLEXECUTEINFO contains a handle to the created process.
With this handle you can call GetExitCodeProcess, which will return STILL_ACTIVE if it is still running, or it's exit code if it has stopped.
If it is stopped, do not forget to call CloseHandle with the process handle.
NOTE: STILL_ACTIVE is defined as 259. Do not call exit( ) or ExitProcess( ) with a value of 259 as exitstatus in any program, or this will not work.
Marcel
 

Thanks very much - Just what I needed.

CMR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top