Click to See Complete Forum and Search --> : WaitForSingleObject...


Michael Bechard
August 11th, 1999, 09:55 AM
I'm trying to write a program that tests certain programs to see if they're still running. I suppose I could use the WaitForSingleObject call, but will that say the program is running even if it is frozen? I've been debating, in light of this question, whether or not MsgWaitForMultipleObjects would elleviate this problem. If someone could clarify the uses of these two calls I would appreciate it. Also any other solutions to my problem would be useful as well.

Vlad Chapranov
August 11th, 1999, 10:17 AM
I know nothing about those APIs. But I think there are cases when a particular program can be presented by several windows in a memory, like Symantec WinFax. In a such case I used to look for all of them by using:
[lngHandle0 = FindWindow("MOD", vbNullString)
lngHandle1 = FindWindow("WFXMOD", vbNullString)
lngHandle2 = FindWindow("WFXIFMODMODTHREADWINDOW", vbNullString)
lngHandle3 = FindWindow("WFXIFEXEMainWindow", vbNullString)
lngHandle4 = FindWindow("#32770", vbNullString)
lngHandle1 = FindWindow("Sfaxmng", vbNullString)
lngHandle2 = FindWindow("Cfaxmng", vbNullString)
lngHandle7 = FindWindow("AVIWnd", vbNullString)]
First parameter is Class of window and you can find it with Spy++ when that particular program is running. Maybe it will help.
Vlad

Michael Bechard
August 11th, 1999, 10:25 AM
My main problem is in determining if the program is responding to Windows messages or not. Will the program retain all the child windows in memory if is is not?

Lothar Haensler
August 11th, 1999, 10:38 AM
In my experience if you use WaitForSingleObject your program will not respond to Windows messages during the wait period.
This is why I usually wait in small intervals like one tenth of a second and use a timer to repeatedly call WaitForSingleObject.
you could probably also use DoEvents as in

lResult = WaitForSingleObject(...)
do while not ...
DoEvents
lResult = WaitForSingleObject(...)
Loop

Michael Bechard
August 11th, 1999, 10:44 AM
Yes, I realise this and planned to do that. But I was wondering if the return value from WaitForSingleObject would indicate if the window was frozen (not receiving Windows messages) or, if it was, indicate it was still running. As an alternative, would MsgWaitForMultpipleObjects work since it monitors certain types of messages in the que for certain objects (I think...). At any rate, thank you for your help.