Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CLOSE = &H10
'以下演示关闭帝国时代
Dim ret As Integer
Dim nFind As Integer
nFind = FindWindow(vbNullString, "age of empires")
If nFind <> 0 Then
' end the program:
SendMessage nFind, WM_CLOSE, 0, 0
' Display a message box:
ret = MsgBox("用户无权运行此程序!", vbCritical + vbOKOnly, "警告")
End If