|
-
Dec 30th, 2001, 03:50 AM
#1
Thread Starter
Member
Error in closing another application...
I tried to open Norton Anti Virus using ShellExecute.
After a few seconds, I tried to close it using SendMessage as below.
But it didn't work. I've done the declaration for the WM_CLOSE and all
the Windows API but still didn't work. Before this, I used PostMessage but
still not working. The return value was 0.
Can anyone guide me? Any other method of closing another application effectively?
Maybe an example or two will be greatly appreaciated... Thanks..
'##################################################################'
'***'in module
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function GetActiveWindow Lib "user32" () As Long
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Public Const WM_CLOSE = &H10
Public Const WM_DESTROY = &H2
'***'in form
Dim retval As Long
Dim hWnd2 As Long
hWnd2 = GetActiveWindow
retval = ShellExecute(hWnd2, "open", "C:\Program Files\Norton SystemWorks\Norton AntiVirus\navw32.exe", "c:\myTemp.txt", 0&, SW_MINIMIZE)
Debug.Print "ShellExecute = " & retval
Sleep 12000
hWnd2 = FindWindow(vbNullString, "Norton AntiVirus")
Debug.Print "findwindow = " & hWnd2
z = SendMessage(hWnd2, WM_CLOSE, 0, 0 )
Debug.Print "z = " & z
z = SendMessage(hWnd2, WM_DESTROY, 0, 0)
Debug.Print "z = " & z
'####################################################################
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|