'Api constants for General Declarations
'Const WM_DESTROY = &H2 Const WM_CLOSE = &H10 ' Api Functions For general declarations Private Declare Function FindWindowA Lib "user32" _ (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer Private Declare Function SendMessageA Lib "user32" _ (ByVal hWnd As Integer, ByVal wMsg As Integer, _ ByVal wParam As Integer, lParam As Any) As Long Private Function Kill(hWnd&) Dim Res& ' Ask it politely to close Res = SendMessageA(hWnd, WM_CLOSE, 0, 0) ' Kill it (just in case) Res = SendMessageA(hWnd, WM_DESTROY, 0, 0) End Function Private Sub cmdKill_Click() Dim hWnd& ' Get the window handle hWnd = FindWindowA(vbNullString, txtName.Text) ' Call the kill Function Kill (hWnd) End Sub |