今天在MSN的核心討論組上看到兩篇文章.討論的乃是應用程序是否沒有響應.原文如下:
> How is it possible to determine a process is "not responding" like NT Task
> Manager do?
The heuristic works only for GUI processes, and consists of calling
SendMessageTimeOut() with SMTO_ABORTIFHUNG.
>There is any API call to do the job, or this status is simply a deduction
>based on process counters, like that returned from call to GetProcessTimes
>API function?
Use SendMessageTimeout with a value of WM_NULL. That's all Task
Manager does to determine this AFAIK.
--
有理有理.當然,我這裡還有一個UNDOCUMENTED函數,乃是其他的解決方案,NT和9X有個USER32.DLL的函數,IsHungAppWindow(NT)和IsHungThread(9X).使用起來簡便無比.下面給出原型.
BOOL IsHungAppWindow (
HWND hWnd, // handle to main app's window
);
BOOL IsHungThread (
DWORD dwThreadId, // The thread's identifier of the main app's window
);
有了原型,連解釋都不需要,好得不的了.:)不過調用時需要GetProcAddress.庫裡沒有該函數.