Results 1 to 5 of 5

Thread: [RESOLVED] Close all open IE Browsers from within VB6

Hybrid View

  1. #1
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: Close all open IE Browsers from within VB6

    avoid killing processes - it causes memory leaks. Just loop through the windows and close them:
    VB Code:
    1. Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" ( _
    2.     ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    3.  
    4. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" ( _
    5.     ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
    6.  
    7. Private Const WM_CLOSE As Long = &H10
    8.  
    9. Private Sub Command1_Click()
    10.     Dim lhWnd As Long
    11.     Do
    12.         lhWnd = FindWindowEx(0&, lhWnd, "IEFrame", vbNullString)
    13.         If lhWnd Then PostMessage lhWnd, WM_CLOSE, 0&, 0&
    14.     Loop While lhWnd
    15. End Sub

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    75

    Re: Close all open IE Browsers from within VB6

    Worked like a charm thanx man!

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