Results 1 to 3 of 3

Thread: Kill a Task/End a Program (out side your program)

  1. #1
    Guest

    Lightbulb

    Any one know how to end task\kill\close\etc. a program. For say I make up a program that creates a icon in the system tray but I don't want the program to "end" it self. I want to make anouther program to end task the system tray icon program. Kind of like the Ctrl-Alt-Delete taskman.exe program. Where you "end task" (I know there is a differecne between end task and close.) a program.

  2. #2
    Addicted Member Geoff Gunson's Avatar
    Join Date
    Jun 1999
    Posts
    241
    Hi

    You nedd to declare these functions / constents

    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 Const WM_CLOSE = &H10

    Private Sub Command1_Click()
    Dim Whnd&, Ret&

    Whnd = FindWindow(vbNullString, "Solitaire")
    If Whnd <> 0 Then
    Ret = SendMessage(Whnd, WM_CLOSE, 0&, 0& )
    End If
    End Sub

    'The above example will close Solitaire game if is running

    HTH

    Geoff

    [Edited by Geoff Gunson on 04-18-2000 at 12:03 PM]

  3. #3
    Guest

    Thanks

    Thanks for the code.

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