// Ishung. cpp (Windows 95/98/NT/2000)
//
// This example will show you how you can obtain the current status
// Of the application.
//
//
// (C) 1999 Ashot Oganesyan K, Smartline, Inc
// Mailto: ashot@aha.ru, http://www.protect-me.com, http://www.codepile.com
# Include <windows. h>
# Include <stdio. h>
// USER32! Ishungappwindow (NT specific !)
//
// The function retrieves the status (running or not responding) of
// Specified application
//
// Bool ishungappwindow (
// Hwnd, // handle to main app's window
//);
Typedef bool (winapi * procishungappwindow) (hwnd );
// USER32! Ishungthread (95/98 specific !)
//
// The function retrieves the status (running or not responding) of
// Specified Thread
//
// Bool ishungthread (
// DWORD dwthreadid, // The identifier of the main app's window thread
//);
Typedef bool (winapi * procishungthread) (DWORD );
Procishungappwindow ishungappwindow;
Procishungthread ishungthread;
Void main (INT argc, char * argv [])
{
If (argc <2)
{
Printf ("Usage: \ n \ nishung.exe hwnd \ n ");
Return;
}
Hwnd;
Sscanf (argv [1], "% lx", & hwnd );
If (! Iswindow (hwnd ))
{
Printf ("Incorrect window handle \ n ");
Return;
}
Hmodule huser32 = getmodulehandle ("USER32 ");
If (! Huser32)
Return;
ishungappwindow = (procishungappwindow)
getprocaddress (huser32,
"ishungappwindow");
Ishungthread = (procishungthread) getprocaddress (huser32,
"Ishungthread ");
If (! Ishungappwindow &&! Ishungthread)
Return;
Osversioninfo osver;
Osver. dwosversioninfosize = sizeof (osversioninfo );
If (! Getversionex (& osver ))
Return;
Bool ishung;
If (osver. dwplatformid & ver_platform_win32_nt)
Ishung = ishungappwindow (hwnd );
Else
Ishung = ishungthread (getwindowthreadprocessid (hwnd, null ));
If (ishung)
printf ("not responding \ n");
else
printf ("running \ n ");
}