调用API 查找到窗体 并关闭

xiaoxiao2021-02-28  111

[DllImport("user32.dll", EntryPoint = "SendMessage")] public static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); [DllImport("User32.dll", EntryPoint = "FindWindow")] private static extern IntPtr FindWindow(string lpClassName, string lpWindowName); public const int WM_SYSCOMMAND = 0x0112; public const int SC_CLOSE = 0xF060; void CloseDownload() { IntPtr hwnd = FindWindow(null, "下载完毕"); if (hwnd == IntPtr.Zero) { return; } SendMessage(hwnd, WM_SYSCOMMAND, (IntPtr)SC_CLOSE, 0); }
转载请注明原文地址: https://www.6miu.com/read-34501.html

最新回复(0)