说明process及ba你没有进行定义 在窗口代码的开头应该有dim process as long,ba as long
'标准模块: Public BA As Long ''''''''''''''' Public PROCESS As Long ''''''''''' Public Const PROCESS_ALL_ACCESS = &H1F0FFF '全权打开进程Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal Hwnd As Long, lpdwProcessId As Long) As Long Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Public Sub add()
HWD = FindWindow(vbNullString, "Plants vs. Zombies 1.2.0.1073 RELEASE") GetWindowThreadProcessId HWD, PID PROCESS = OpenProcess(PROCESS_ALL_ACCESS, False, PID) ReadProcessMemory PROCESS, ByVal &H7794F8, BA, 4, 0& ReadProcessMemory PROCESS, ByVal BA + &H868, BA, 4, 0& End Sub
在窗口代码的开头应该有dim process as long,ba as long
'标准模块:
Public BA As Long '''''''''''''''
Public PROCESS As Long '''''''''''
Public Const PROCESS_ALL_ACCESS = &H1F0FFF '全权打开进程Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal Hwnd As Long, lpdwProcessId As Long) As Long
Public Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
Public Sub add()
HWD = FindWindow(vbNullString, "Plants vs. Zombies 1.2.0.1073 RELEASE")
GetWindowThreadProcessId HWD, PID
PROCESS = OpenProcess(PROCESS_ALL_ACCESS, False, PID)
ReadProcessMemory PROCESS, ByVal &H7794F8, BA, 4, 0&
ReadProcessMemory PROCESS, ByVal BA + &H868, BA, 4, 0&
End Sub