danclemson
December 19th, 2002, 01:20 PM
Hi, All
I am trying to use the following VB .Net code (originated from VB code) to close applicaiton. The applicaiton is not closing.
Please let me know what is the problem.
Thanks /dan
'*************************************************
Module Module1
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
Sub Main()
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "Calculator")
If winHwnd <> 0 Then
PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
MsgBox(winHwnd)
Else
MsgBox("The Calculator is not open.")
End If
End Sub
End Module
I am trying to use the following VB .Net code (originated from VB code) to close applicaiton. The applicaiton is not closing.
Please let me know what is the problem.
Thanks /dan
'*************************************************
Module Module1
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
Sub Main()
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "Calculator")
If winHwnd <> 0 Then
PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
MsgBox(winHwnd)
Else
MsgBox("The Calculator is not open.")
End If
End Sub
End Module