Article ID: 153463
Article Last Modified on 6/29/2004
Option Explicit
Private Declare Function FindWindow Lib "User" (ByVal lpClassName _
As Any, ByVal lpWindowName As Any) As Integer
Private Declare Function PostMessage Lib "User" (ByVal hWnd _
As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, _
lParam As Any) As Integer
Private Const WM_QUIT = &H12
Private Sub Command1_Click()
Dim sTitle As String
Dim iHwnd As Integer
Dim ihTask As Integer
Dim iReturn As Integer
sTitle = "Notepad - (Untitled)"
iHwnd = FindWindow(0&, sTitle)
iReturn = PostMessage(iHwnd, WM_QUIT, 0, 0&)
MsgBox "Notepad has been Closed Down"
End Sub
Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As Any, ByVal lpWindowName As Any) 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
Private Const WM_QUIT = &H12
Private Sub Command1_Click()
Dim sTitle As String
Dim iHwnd As Long
Dim ihTask As Long
Dim iReturn As Long
sTitle = "Untitled - Notepad"
iHwnd = FindWindow(0&, sTitle)
iReturn = PostMessage(iHwnd, WM_QUIT, 0&, 0&)
MsgBox "Notepad has been Closed Down"
End Sub
Keywords: kbhowto KB153463