Dim WINHWND As Long<br>Dim VAL As Long<br>Global Const WM_CLOSE = &H10<br><br>Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long<br>Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long<br><br>Private Sub Command1_Click()<br>WINHWND = FindWindow(vbNullString, "无标题 - 记事本")<br>If WINHWND = 0 Then MsgBox "找不到窗口"<br>If WINHWND <> 0 Then<br>S2 = SendMessage(WINHWND, WM_CLOSE, 0&, 0&<br>End If<br>If S2 <> 0 Then MsgBox "关闭失败”"<br>End Sub