查了些资料,正在整理中。现在记录一下:
Process有此属性,获取了Process后直接判断Responding属性即可。
<span style="white-space:pre"> </span>#region 窗体是否挂起 [DllImport("User32.dll", CharSet = CharSet.Auto)] public static extern bool IsHungAppWindow(IntPtr hwnd); #endregion
声明方法为:
public enum SendMessageTimeoutFlags : uint { SMTO_NORMAL = 0x0, SMTO_BLOCK = 0x1, WM_NULL = 0, SMTO_ABORTIFHUNG = 0x2, SMTO_NOTIMEOUTIFNOTHUNG = 0x8 }
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)] public static extern IntPtr SendMessageTimeout( IntPtr windowHandle, uint Msg, IntPtr wParam, IntPtr lParam, SendMessageTimeoutFlags flags, uint timeout, out uint result);
public static bool IsExeNotResponse(IntPtr hwnd) { var lRes = uint.MinValue; //Register the message var lMsg = RegisterWindowMessage("WM_HTML_GETOBJECT"); //Get the object SendMessageTimeout(hwnd, lMsg, IntPtr.Zero, IntPtr.Zero, SendMessageTimeoutFlags.WM_NULL, 1000, out lRes); return lRes == 0; }
这几个方法都是可行的,但是我们需要具体问题具体分析。我还没有搞清楚这三种方法适用的情况,以后补上吧。