这个API反一转用才更有意思,先枚举某窗口上的所有hwnd,然后把他们全部EnableWindow(hwnd, true),变的可用,这样许多弱智的共享软件,就能使用了!!
这个不好玩,强行关了他更好玩
' FindWindow函数声明
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String _
) As Long
' PostMessage函数声明
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any _
) As Long
'关闭程序需要的常量
Const WM_CLOSE = &H10
Private Sub Command1_Click()
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "QQ用户登录")
Debug.Print winHwnd
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal = 0 Then
MsgBox "关闭QQ出错!"
End If
Else
MsgBox "QQ没有运行。"
End If
End Sub