VB 從零開始編外掛(一)
2024-07-21 02:20:41
供稿:網友
需要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