- UID
- 188843
- 帖子
- 5
- 主題
- 3
- 精華
- 0
- 積分
- 3
- 楓幣
- 135
- 威望
- 3
- 存款
- 0
- 贊助金額
- 0
- 推廣
- 0
- GP
- 53
- 閱讀權限
- 10
- 性別
- 男
- 在線時間
- 3 小時
- 註冊時間
- 2017-5-21
- 最後登入
- 2024-7-11
|
Public Function OpenProcessByProcessName(ByVal lpName As String) As Long
Dim PE32 As PROCESSENTRY32
Dim hSnapshot As Long
pid = 0
hSnapshot = CreateToolhelp32Snapshot(2, 0&) 'TH32CS_SNAPPROCESS = 2
PE32.dwSize = Len(PE32)
Process32First(hSnapshot, PE32)
While pid = 0 And CBool(Process32Next(hSnapshot, PE32))
If Right$(LCase$(Left$(PE32.szExeFile, InStr(1, PE32.szExeFile, Chr(0)) - 1)), Len(lpName)) = LCase$(lpName) Then
pid = PE32.th32ProcessID
End If
End While
CloseHandleAPI(hSnapshot)
OpenProcessByProcessName = OpenProcess()
End Function
Public Function OpenProcessByWindow(ByVal lpWindowName As String, Optional ByVal lpClassName As String = vbNullString) As Long
hWnd = FindWindow(lpClassName, lpWindowName)
GetWindowThreadProcessId(hWnd, pid)
OpenProcessByWindow = OpenProcess(pid)
hprocess = OpenProcessAPI(PROCESS_ALL_ACCESS, False, pid)
End Function
End Module
OpenProcessByWindow("惡犬谷", "StartUpDlgClass")
If pid <> 0 Then
MsgBox("遊戲鎖定成功囉!", 64, "FirstProject_Tipe")
Else
MsgBox("鎖定遊戲失敗!", 16, "FirstProject_Error")
End If
End Sub
End Class
怎麼偵測不到 |
|