Results 1 to 4 of 4

Thread: closing programs

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    183

    Unhappy

    Lets say that I`m running internet explorer (or any other program for that matter) and I want to have a button on my visual basic program to close it. Any idea how?
    I tried using (sendmessage and WM_DESTROY) but it makes the program freeze...

    Any one have an idea??

  2. #2
    Fanatic Member
    Join Date
    Oct 1999
    Location
    MA, USA
    Posts
    523
    How about sending WM_CLOSE first and after that WM_DESTROY? (or DESTROY-CLOSE I forgot which one it is)

    Or use CloseWindow API
    Code:
    Public Declare Function CloseWindow Lib "user32" Alias "CloseWindow" (ByVal hwnd As Long) As Long
    Post #517

    [Edited by QWERTY on 08-09-2000 at 12:33 AM]

  3. #3
    New Member
    Join Date
    Aug 2000
    Posts
    4

    Closing Application

    I also had a problem killing applications, particularly Internet Explorer with the SendMessage.

    What I used instead was the PostMessage.

    if this is some help

    Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

    G Luck

    ~Q~
    ~QUBi~

  4. #4
    Guest
    Try this:
    Code:
    Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    Const WM_CLOSE = &H10
    
    Private Sub Command1_Click()
        Dim hApp As Long
        hApp = FindWindow("IEFrame", vbNullString)
        PostMessage hApp, WM_CLOSE, 0, 0
        DestroyWindow hApp
    End Sub

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