CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2001
    Posts
    24

    Closing a app from other app...using VB?

    I want to kill a process from my application
    how to do that??
    expecting details.....
    Rgds,
    Vishal


    :-)

  2. #2
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: Closing a app from other app...using VB?

    Find window handle and then terminate this window

    Declare Function GetWindowThreadProcessId Lib "user32" (ByVal Hwnd As Long, lpdwProcessId As Long) As Long


    Declare Function TerminateProcess Lib "kernel32" (ByVal ApphProcess As Long, ByVal uExitCode As Long) As Long


    Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal blnheritHandle As Long, ByVal dwAppProcessId As Long) As Long


    Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
    Const PROCESS_ALL_ACCESS = 0


    Function KillWindow(Hwnd)
    Dim PROCESSID As Long
    Dim exitcode As Long
    Dim MyProcess As Long
    Call GetWindowThreadProcessId(Hwnd, PROCESSID) ' Get the processid from the window
    MyProcess = OpenProcess(PROCESS_ALL_ACCESS, False, PROCESSID) ' open the process by processid
    AppKill = TerminateProcess(MyProcess, exitcode) ' Terminate the process by process
    Call CloseHandle(MyProcess) ' close the process
    End Function


    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  3. #3
    Join Date
    Dec 1999
    Location
    Dublin, Ireland
    Posts
    1,173

    Re: Closing a app from other app...using VB?

    Try sending a WM_CLOSE message to it.

    See http://www.merrioncomputing.com/vb_killapp.htm

    HTH,
    Duncan

    -------------------------------------------------
    Ex. Datis: Duncan Jones
    Merrion Computing Ltd
    http://www.merrioncomputing.com
    '--8<-----------------------------------------
    NEW -The printer usage monitoring application
    '--8<------------------------------------------

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

Featured