Results 1 to 2 of 2

Thread: Close another program from vb application

  1. #1
    Guest

    Post

    How can i close another program(exe)using vb application?

    -Khamal-

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    If you know the Window Handle (hWnd) of that window, then you can do something like this:

    Code:
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Private Const WM_DESTROY = &H2
    
    
    Private Sub Command1_Click()
        Dim lHwnd As Long
        
        'lHwnd should be your hWnd of the program you want to close
        Call SendMessage(lHwnd, WM_DESTROY, 0, 0)
    End Sub
    ------------------

    Serge

    Senior Programmer Analyst
    sdymkov@microage.com
    Access8484@aol.com
    ICQ#: 51055819

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