C#webbrowser弹出窗口“来自网页的消息”如何自动关闭 50
代码如下:publicconstintWM_CLOSE=0x10;[DllImport("user32.dll",EntryPoint="SendMessageA")]p...
代码如下:public const int WM_CLOSE = 0x10; [DllImport("user32.dll", EntryPoint = "SendMessageA")] 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); private void close_win() { IntPtr hwnd; hwnd = FindWindow(null, "来自网页的消息"); SendMessage(hwnd, WM_CLOSE, 0, 0); }private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { Thread t = new Thread(close_win); t.Start();}我在另一个测试这段代码能在Form1把Form2关掉,但是这个弹窗却关不掉,求解
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询