InPowerS.Net

 找回密碼
 註冊
搜索
查看: 2168|回復: 0

[轉貼]VB 從零開始編外掛(一)

[複製鏈接]
發表於 2008-12-25 21:57:39 | 顯示全部樓層 |閱讀模式
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要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
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要的控制項:Label、Timer
--------------------------------------------------------------------------------------------------------------------------------------------------------   自訂函數:
Dim hwnd 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
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
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

小黑屋|Archiver|手機版|InPowerS.Net

GMT+8, 2018-8-18 07:12

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回復 返回頂部 返回列表