|
-
Mar 20th, 2000, 02:05 PM
#1
Thread Starter
Hyperactive Member
I need to close my browser from my VB application. I tried using the CloseHandle API but it doesnt work. How do I make it work?
Thanx in advance for the time and effort spent,
Ramya.
-
Mar 21st, 2000, 04:03 AM
#2
Junior Member
You have to get the window of the handle of your browser then close it.
Put this code in a module :
Option Explicit
Declare Function FindWindow Lib "user32" Alias _
"FindWindowA" (ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Declare Function PostMessage Lib "user32" Alias _
"PostMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, lParam As Any) As Long
Public Const WM_CLOSE = &H10
This code in a button or form load :
Dim winHwnd As Long
Dim RetVal As Long
winHwnd = FindWindow(vbNullString, "Your browser Window Name")
If winHwnd <> 0 Then
RetVal = PostMessage(winHwnd, WM_CLOSE, 0&, 0&)
If RetVal = 0 Then
MsgBox "Cannot close this Window"
End If
Else
MsgBox "Your Browser isn't open"
End If
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
|