Results 1 to 2 of 2

Thread: closing the browser

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2000
    Location
    India
    Posts
    298
    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.

  2. #2
    Junior Member
    Join Date
    Feb 2000
    Location
    England
    Posts
    26
    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
  •  



Click Here to Expand Forum to Full Width