判断窗口是否挂起
2006-02-16 22:55
218 查看
// 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 the
// specified application
//
// BOOL IsHungAppWindow(
// HWND 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 the
// 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 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");
}
//
// 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 the
// specified application
//
// BOOL IsHungAppWindow(
// HWND 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 the
// 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 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");
}
相关文章推荐
- 判断一个窗口是否被挂起(发WM_NULL消息,或者调用IsHungAppWindow API进行测试)
- 判断一个窗口是否被挂起【小记】?
- 判断一个窗口是否被挂起【小记】?
- 判断一个窗口是否被挂起【小记】?
- NtQuerySystemInformation判断线程是否被挂起/判断线程状态
- PB判断数据窗口数据是否更改及原始值与当前值
- 判断窗口是否被完全遮挡的方法
- js 关闭窗口时判断表单数据是否改变
- 判断窗口是否已经被打开
- TopTaskHelper 判断顶层窗口是否变化
- 判断某个窗口是否是活动窗口(当前正在使用、操作的窗口)
- 如何判断一个窗口是否可以接受字符
- 判断一个view是否在主窗口
- 【WM】如何判断两个窗口是否由同一进程创建
- 判断窗口是否退出
- C# 判断窗口是否打开
- js判断当前窗口是否是顶级窗口
- 用javascript 判断IE窗口是否打开
- 判断元素是否可见的jQuery 新窗口打开图片
- 使用javascript判断IE是否阻止弹出窗口