Results 1 to 4 of 4

Thread: See if and app is running and stop it?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Location
    Texas
    Posts
    313

    Question

    Is their anyway to check to see if something for example Yahoo pager was running, and tell my computer to shut it down whenever it was running?

  2. #2
    Guest
    Use the FindWindow API.

    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
    Const WM_CLOSE = &H10
    Const WM_DESTROY = &H2
    
    Private Sub Command1_Click()
    
        'Get the hWnd of the App
        hParent = FindWindow(vbNullString, "MyAppTitle")
        'If it's found then close it
        If hParent <> 0 Then
            SendMessage hParent, WM_CLOSE, 0, 0
            SendMessage hParent, WM_CLOSE, 0, 0
        End If
        
    End Sub

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2000
    Location
    Texas
    Posts
    313

    Thank you

    Thanks! I will test it when i get home from work but thank you so much!

  4. #4
    Guest
    If you know the exe, than you can do it this way: App List and Kill and you can add this code to search for it:

    Code:
    'Either:
    For i = 0 to List1.ListCount - 1
    If List1.List(i) = "C:\Program Files\Yahoo\Yahoo Pager.exe" Then Msgbox "Yahoo Page is open!":Exit Sub' change it to whatever the exe's name is.
    Next i
    
    'Or:
    
    For i = 0 to List1.ListCount - 1
    List1.ListIndex = List1.ListIndex + 1
    If List1 = "C:\Program Files\Yahoo\Yahoo Pager.exe" Then Msgbox "Yahoo Pager is open!":Exit Sub
    Next i

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