VB查找指定名称窗口并发送消息,VB查找指定名称窗口发送消息,VB查找指定窗口发送消息,VB查找窗口发送消息,VB指定窗口发送消息,VB窗口发送消息,VB窗口消息,VB窗口,FindWindow(vbNullString, "Windows 文件保护"),PostMessage(hwnd, WM_QUIT, 0, 0),VB 关闭Windows 文件保护窗口,VB 关闭Windows 窗口,VB 关闭文件保护窗口,VB 关闭Windows 文件保护,VB Windows 文件保护窗口,VB Windows 文件保护,VB 关闭窗口。

VB查找指定名称窗口并发送消息:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long '查找窗口
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long '发送消息
Private Const WM_QUIT = &H12
Dim hwnd  As Long                                                               '定义存放"Windows 文件保护"窗口句柄的变量
hwnd = FindWindow(vbNullString, "Windows 文件保护")                             '查找"Windows 文件保护"窗口,并把对应的句柄存入变量
If hwnd <> 0 Then Call PostMessage(hwnd, WM_QUIT, 0, 0)                         '如果窗口存在则退出窗口

VB查找指定名称窗口并发送消息精简代码:

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long '查找窗口
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long '发送消息
Private Const WM_QUIT = &H12
If FindWindow(vbNullString, "Windows 文件保护") <> 0 Then Call PostMessage(FindWindow(vbNullString, "Windows 文件保护"), WM_QUIT, 0, 0) '如果窗口存在则关闭窗口

部分常量参数值:

Private Const WM_QUIT = &H12
退出:WM_QUIT
隐藏:SW_HIDE
Private Const WM_QUIT = &H10
关闭:WM_CLOSE
Private Const WM_LBUTTONDOWN = &H201
鼠标左键按下:WM_LBUTTONDOWN
Private Const WM_KEYDOWN = &H100
Private Const WM_KEYUP = &H101
Private Const WM_MOUSEMOVE = &H200
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Private Const WM_LBUTTONDBLCLK = &H203
Private Const WM_RBUTTONDOWN = &H204
Private Const WM_RBUTTONUP = &H205
Private Const WM_RBUTTONDBLCLK = &H206
Private Const WM_MBUTTONDOWN = &H207
Private Const WM_MBUTTONUP = &H208
Private Const WM_MBUTTONDBLCLK = &H209
Private Const WM_MOUSEWHEEL = &H20A
Private Const WM_SYSTEMKEYDOWN = &H104
Private Const WM_SYSTEMKEYUP = &H105