I need to use ShellExecute() (or ShellExecuteEx()) to run the app associated with a file. So far no problem....
However, I then need to wait for the application launched by ShellExecute(Ex) to end. So I need the process handle to use with WaitForSingleObject(). And I can't find a reliable way to get the process handle (or process id).
Every technique I looked at has a problem:
1. ShellExecuteEx doesn't always return the HPROCESS. e.g. if Word is already running before calling ShellExecuteEx() the HPROCESS returned is NULL.
2. Using a kernel mode driver to access the native NT object manager requires that the user has service install priveleges - which won't always be the case (this is the technique used by HandleEx, www.sysinternals.com
, and it's clones on www.codeguru.com
). It also means relying on undocumented functionality in NT. :-(
Can anyone help?
(My target OS is NT4, Win2K & XP)