vb子程序或函数未定义

来源:百度知道 编辑:UC知道 时间:2024/05/25 11:48:15
Dim hwd As Long
Dim pid As Long
Dim hProcess As Long '存放进程句柄
Private Sub Form_Load()
hwd = FindWindow("ElementClient Window", "Element Client")
If hwd = 0 Then
MsgBox "未启动游戏", vbOKOnly, "提示"
Unload Form1
End If
GetWindowThreadProcessId hwd, pid '获取进程标识符
'将进程标识符做为参数,返回目标进程PID的句柄,得到此句柄后
'即可对目标进行读写操,PROCESS_ALL_ACCESS表示完全控制,权限最大
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
If hProcess = 0 Then
MsgBox "不能打开进程", vbOKOnly, "提示"
Unload Form1
End If
CloseHandle hProcess
End Sub

Private Sub Timer1_Timer()
Dim base As Long '存放人物基地址
Dim h As Long
Dim i As Long
Dim name(31) As Byte
Dim name_temp As Long
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
If hProcess Then
ReadProcessMemory hProcess, ByVal &H405344, h, 4, 0&
ReadProcessMemory h

hwd = FindWindow
hProcess = OpenProcess
是不是API函数啊,你没定义api嘛,在代码的声明部分声明一下API:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function OpenProcess Lib "kernel32" Alias "OpenProcess" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long

看别人的程序是最难受的
而且VB是分版面的
每个版都是一套独立的代码
要是你自己编写的就自己找找错误
编程工具一般都会提示你,说子程序未定义就看看是不是忘定义了
变成最困难的就是调试了
不过自己去解决才是获得真知的唯一最好途径
希望你成功