Determines whether the window is suspended

Source: Internet
Author: User

// 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 ");
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.