1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
UpdateData();
CWnd* hwnd = FindWindow(NULL, m_szName);// m_szName 程序名称

if (NULL != hwnd)
{
HINSTANCE hDll = LoadLibrary(_T("user32.dll"));
if (NULL != hDll)
{
typedef BOOL(WINAPI *PROCISHUNGAPPWINDOW)(HWND);
PROCISHUNGAPPWINDOW IsHungAppWindow = (PROCISHUNGAPPWINDOW)GetProcAddress(hDll, "IsHungAppWindow");
if (IsHungAppWindow(hwnd->GetSafeHwnd()))
{
m_szStatus = "未响应";
}
else
{
m_szStatus = "正在运行";
}
}
// LoadLibrary();
// IsHungAppWindow();
// IsHungThread();
}
else
{
m_szStatus = _T("未检测到程序状态!");
}
UpdateData(FALSE);

代码调用了User32.dll中一个未公开的函数,这个函数存在于Win 9x和Win NT/2000两个操作系统之中,
Win 9x为IsHungThread;在Win NT/2000中为IsHungAppWindow。