当前位置:首页>>网络编程>>VB教程>>正文

VB从零开始编外挂(一)

来源:设计前沿收集 作者:未知 时间:2006-07-28
需要VBAPI函数:
FindWindow←寻找窗口列表中第一个符合指定条件的顶级窗口
GetWindowThreadProcessId←获取与指定窗口关联在一起的一个进程和线程标识符
--------------------------------------------------------------------------------------------------------------------------------------------------------
相关API声明:
FindWindow

PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,ByVallpWindowNameAsString)AsLong

GetWindowThreadProcessId

PrivateDeclareFunctionGetWindowThreadProcessIdLib"user32"(ByValhwndAsLong,lpdwProcessIdAsLong)
AsLong
--------------------------------------------------------------------------------------------------------------------------------------------------------
需要的控件:Label、Timer
--------------------------------------------------------------------------------------------------------------------------------------------------------自定义函数:
DimhwndAsLong
--------------------------------------------------------------------------------------------------------------------------------------------------------源代码:
PrivateDeclareFunctionFindWindowLib"user32"Alias"FindWindowA"(ByVallpClassNameAsString,ByVallpWindowNameAsString)AsLong
PrivateDeclareFunctionGetWindowThreadProcessIdLib"user32"(ByValhwndAsLong,lpdwProcessIdAsLong)AsLong
PrivateSubTimer1_Timer()
DimhwndAsLong'储存FindWindow函数返回的句柄
hwnd=FindWindow(vbNullString,"WindowsMediaPlayer")'取得进程标识符
'只要把WindowsMediaPlayer换成游戏的名称就可了!
Ifhwnd=0Then
Label1.Caption="游戏未运行"
Else
Label1.Caption="游戏已运行"
EndIf
EndSub
->