Results 1 to 5 of 5

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

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    75

    Resolved [RESOLVED] Close all open IE Browsers from within VB6

    Hey Guys,

    Does anyone know how to close all open ie browsers from within vb6?

  2. #2
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Close all open IE Browsers from within VB6

    ud have to get the process.. (iexplore.exe) and kill it...

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Mar 2006
    Posts
    75

    Re: Close all open IE Browsers from within VB6

    How would I kill a process in vb6?

  4. #4
    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

  5. #5

    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