|
-
Aug 12th, 2000, 11:12 AM
#1
Thread Starter
Hyperactive Member
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?
-
Aug 12th, 2000, 11:21 AM
#2
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
-
Aug 12th, 2000, 11:23 AM
#3
Thread Starter
Hyperactive Member
Thank you
Thanks! I will test it when i get home from work but thank you so much!
-
Aug 12th, 2000, 12:13 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|