Results 1 to 5 of 5

Thread: Terminating a running application

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    3

    Terminating a running application

    Hello. I need to terminate a running process/application given its ".exe" name. I found the FindWindow API but its parameter is the application name and not the ".exe" name (for example, "Notepad - Untitled" instead of "notepad.exe". I also tried using TerminateProcess API but it can only terminate a process created by CreateProcess API. I need help badly.

  2. #2
    KamranAslam
    Guest
    Go to this site and u will find the solution to your problem .
    http://www.blackbeltvb.com/

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    3
    Thank you for your response. If you are referring to the module using TerminateProcess API then that is not what I need. As I said, TerminateProcess can only kill applications created either by shell function of CreateProcess API. The application that I am supposed to terminate is NOT created/run through shell function or CreateProcess but by an independent application.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333
    VB Code:
    1. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    2. 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
    3.  
    4. Private Const WM_CLOSE = &H10
    5.  
    6. Private Sub cmdCloseApp_Click()
    7. Dim CloseIt As Long
    8. CloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
    9. PostMessage CloseIt, WM_CLOSE, CLng(0), CLng(0)
    10. End Sub

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2002
    Posts
    3
    Thanks again for the reply. I cant use FindWindow either because the applicatio I am suppose to terminate has NO WINDOW. I need something that can close an application given its ".exe" name.

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