In addition to what LNogueira already said, you can use the
WaitForSingleObject Function (Windows)[
^] from the
Win32 API (you can use it directly from
C++ or by marshalling from
C# and
VB).
If you pass the process handle of
outlook.exe to this function, with the second parameter equal to
INFINITE
(
INFINITE
is defined in WinBase.h as
0xFFFFFFFF
), the function does not return until the specified process terminates (it doesn't matter how it terminates).
Then you can work this way:
- Test if the process outlook.exe is running
- If outlook.exe is not running wait for a while then return to the step (1); otherwise go on with the step (3)
- Save the current time (this is the time when outlook is started)
- Get the handle of the outlook.exe process
- Call
WaitForSingleObject
to wait until the outlook.exe process terminates - Get the current time and update your statistics
- Return to the step (1)