- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using ShellExecuteEx to invoke hh.exe with an appropriate mapid. When my help file does not contain a topic with the sent mapid hh.exe exits. I would like to be able to pick this up in the calling application possibly by checking whether the process is still running or not. I have set %fmask=See_Mask_NoCloseProcess and get a %hprocess number returned. I note from looking at the Task Manager that this number is not the PID of the process so first question is how does hprocess relate to PID. Second question is how to check whether or not hprocess has terminated?
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming that hh.exe exits with some non-zero status if the mapid is invalid, I'd suggest using GetExitCodeProcess. You could do this in a loop with a sleep of 100ms or so, calling repeatedly until it no longer returns STILL_ACTIVE (259). Make sure you close the handle when you are done with it.
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hprocess is a handle, which is, in reality, the address of an OS data structure referring to the process. You use WaitForSingleObject to wait for the process to terminate.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I wonder if you could give a little more information Steve. What I think I want is to be able to specify a routine to be called when the process started by ShellExecuteEx terminates and then to take some action if it terminated itself as a result of an invalid mapid. I don't see how WaitForSingleObject helps in this respect.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Assuming that hh.exe exits with some non-zero status if the mapid is invalid, I'd suggest using GetExitCodeProcess. You could do this in a loop with a sleep of 100ms or so, calling repeatedly until it no longer returns STILL_ACTIVE (259). Make sure you close the handle when you are done with it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That works a treat. Thanks Steve.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page