根据窗口句柄判断程序运行状态

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
BOOL CHungDlg::ProcessRunStatus(HWND hwnd)
{
HINSTANCE hDll = LoadLibrary(_T("user32.dll"));
if (NULL != hDll)
{
typedef BOOL(WINAPI *PROCISHUNGAPPWINDOW)(HWND);
PROCISHUNGAPPWINDOW IsHungAppWindow = (PROCISHUNGAPPWINDOW)GetProcAddress(hDll, "IsHungAppWindow");

if (IsHungAppWindow(hwnd))
{
MessageBox("未响应");
CloseApp(hwnd);// 结束进程
return FALSE;
}
else
{
MessageBox("正在运行");
return TRUE;
}
}
return FALSE;
}