Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _ lpClassName As String, ByVal lpWindowName As String) As Long Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal _ hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _ lParam As Any) As Long Const WM_CLOSE = &H10
Sub CloseDosWindow(Optional Caption As Variant) Dim hWnd As Long If IsMissing(Caption) Then Caption = vbNullString hWnd = FindWindow("ConsoleWindowClass", Caption) If hWnd Then SendMessage hWnd, WM_CLOSE, 0, ByVal 0 End If
End Sub |