Results 1 to 2 of 2

Thread: [RESOLVED] how to stop running programs from vb

  1. #1

    Thread Starter
    Member
    Join Date
    May 2007
    Location
    Delhi
    Posts
    34

    Resolved [RESOLVED] how to stop running programs from vb

    Sir,
    I want to know how a running application/program could be stopped/closed through vb code.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: how to stop running programs from vb

    Code:
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
    
    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
    
    Private Const WM_CLOSE = &H10
    Private Const WM_QUIT = &H12
    
    Private Sub cmdCloseApp_Click()
    Dim lngCloseIt As Long
    lngCloseIt = FindWindow(vbNullString, "Caption Of Window To Be Closed")
    PostMessage lngCloseIt, WM_CLOSE, CLng(0), CLng(0)
    End Sub
    
    'Occassionally WM_QUIT is necessary to use

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