1,486
社区成员
发帖
与我相关
我的任务
分享
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As String) As Integer '发送窗口消息
Private Declare Auto Function FindWindow Lib "user32" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer '根据标题查找窗口句柄
Private Declare Auto Function SetForegroundWindow Lib "USER32.DLL" (ByVal hWnd As IntPtr) As Boolean '强制指定句柄的窗口的外部程序获取焦点
hWnd = FindWindow(vbNullString, "Microsoft Internet Explorer")
'关闭指定句柄窗口
Const WM_CLOSE = &H10
SendMessage(hWnd, WM_CLOSE, 0, 0)