Results 1 to 4 of 4

Thread: How do I close a program running?

  1. #1

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Question

    Hi...
    Let's say I have a program running, when I press Alt+Ctrl+Del, I see its name "ABCD".
    It is running in the background, I wanna FORCE the program "ABCD" to exit.

    How do I do that?
    Thanks.

  2. #2
    Guest
    Here's a good example on how to list all the applications running in a listbox and than kill them.

    App List and Kill

  3. #3
    Guest
    Send the WM_CLOSE message with the DestroyWindow function. This example will close Calculator.
    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    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 Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As Long
    Const WM_CLOSE = &H10
    
    Private Sub Command1_Click()
    
        Dim hApp As Long
        hApp = FindWindow(vbNullString, "Calculator")
        Call SendMessage(hApp, WM_CLOSE, 0, 0)
        Call DestroyWindow(hApp)
    
    End Sub

  4. #4

    Thread Starter
    Registered User Lior's Avatar
    Join Date
    Jan 2000
    Posts
    307

    Thanks.

    Thank u, Megatron.
    Worked.

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