VB Code:
Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" (ByVal lpClassName As String, ByVal _
lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" _
Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Const WM_CLOSE = &H10
Const WM_DESTROY = &H2
Private Sub Command1_Click()
hWin = FindWindow("notepad", vbNullString)
If hWin <> 0 Then
PostMessage hWin, WM_CLOSE, 0, 0
PostMessage hWin, WM_DESTROY, 0, 0
End If
End Sub