VB API函數:
FindWindow ←尋找窗口列表中第一個符合指定條件的頂級窗口
GetWindowThreadProcessId ←獲取與指定窗口關聯在一起的一個進程和線程標識符
相關API聲明:
FindWindow
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
GetWindowThreadProcessId
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
參考代碼:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long)As Long
'利用TIMER刷新
Private Sub Timer1_Timer()
Dim hwnd As Long' 儲存 FindWindow 函數返回的句柄
hwnd = FindWindow(vbNullString, "Windows Media Player")' 取得進程標識符
'只要把Windows Media Player換成遊戲的名稱就可了!
If hwnd = 0 Then
Label1.Caption = "遊戲未運行"
Else
Label1.Caption = "遊戲已運行"
End If
End Sub
訂閱:
張貼留言 (Atom)
0 留言:
張貼留言