在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
如何找到桌面上报错的窗口,不管是父窗口还是子窗口,而且获得它的出错信息呢? 复制 保存
[DllImport("user32.dll")]
public static extern int FindWindowEx(int hwndParent, int hwndChildAfter,
string lpszClass, string lpszWindow);
[DllImport("user32.dll")]
public static extern int FindWindow(string strclassName, string strWindowName);
[DllImport("user32.dll")]
public static extern int GetLastActivePopup(int hWnd);
[DllImport("user32.dll")]
public static extern int AnyPopup();
[DllImport("user32.dll")]
public static extern int GetWindowText(int hWnd, StringBuilder lpString, int nMaxCount);
[DllImport("user32.dll")]
public static extern int EnumThreadWindows(int dwThreadId, CallBack lpfn, int lParam);
[DllImport("user32.dll")]
public static extern int EnumWindows(CallBack lpfn, int lParam);
[DllImport("user32.dll")]
public static extern int EnumChildWindows(int hWndParent, CallBack lpfn, int lParam);
复制 保存
/// <summary> /// 回调函数代理 /// </summary> public delegate bool CallBack(int hwnd, int lParam);
复制 保存
/// <summary> /// 进程回调处理函数 /// </summary> /// <param name="hwnd"></param> /// <param name="lParam"></param> /// <returns></returns> public static bool ThreadWindowProcess(int hwnd, int lParam) { EnumChildWindows(hwnd, callBackEnumChildWindows, 0); return true; } /// <summary> /// 窗口回调处理函数 /// </summary> /// <param name="hwnd"></param> /// <param name="lParam"></param> /// <returns></returns> public static bool WindowProcess(int hwnd, int lParam) { EnumChildWindows(hwnd, callBackEnumChildWindows, 0); return true; } /// <summary> /// 子窗口回调处理函数 /// </summary> /// <param name="hwnd"></param> /// <param name="lParam"></param> /// <returns></returns> public static bool ChildWindowProcess(int hwnd, int lParam) { StringBuilder title = new StringBuilder(200); int len; len = GetWindowText(hwnd, title, 200); if (len > 0) { if (title.ToString().IndexOf(GlobalManager.ErrorMessage) != -1) { FindError = true; } } return true; }
复制 保存
/// <summary> /// 进程窗口回调函数代理 /// </summary> public static CallBack callBackEnumThreadWindows = new CallBack(ThreadWindowProcess); /// <summary> /// 窗口回调函数代理 /// </summary> public static CallBack callBackEnumWindows = new CallBack(WindowProcess); /// <summary> /// 子窗口回调函数代理 /// </summary> public static CallBack callBackEnumChildWindows = new CallBack(ChildWindowProcess);
复制 保存
/// <summary> /// 客户端是否弹出对话框 /// </summary> /// <returns></returns> public bool IsClientPopupWindows() { bool FindError = false; EnumWindows(callBackEnumWindows, 0); return FindError; } |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论