-------------------------------------------------------------------------------------------------------------------------------------------------------- 应用实战 -------------------------------------------------------------------------------------------------------------------------------------------------------- 需要VB API函数: FindWindow GetWindowThreadProcessId OpenProcess ReadProcessMemory CloseHandle -------------------------------------------------------------------------------------------------------------------------------------------------------- 相关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
OpenProcess ↓ Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
ReadProcessMemory ↓ Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
CloseHandle ↓ Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
GetCurrentProcess ↓ Private Declare Function GetCurrentProcess Lib "kernel32" () As Long -------------------------------------------------------------------------------------------------------------------------------------------------------- 需要的控件:Label、Timer(interval不为空)、Text -------------------------------------------------------------------------------------------------------------------------------------------------------- 定义函数: Dim SetHp As Integer '''' 定义设定的体力值 Dim SetMp As Integer '''' 定义设定的魔法值 Dim NowHp As Long '''' 定义目前的体力值 Dim NowMp As Long '''' 定义目前的魔法值 Dim MaxHp As Long '''' 定义角色的最高体力值 Dim MaxMp As Long '''' 定义角色的最高魔法值 Dim DiZhi As Long ''''定义内存地址函数 Dim hwnd As Long '''' 储存 FindWindow 函数返回的句柄 -------------------------------------------------------------------------------------------------------------------------------------------------------- 代码: 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 Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long Private Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Declare Function GetCurrentProcess Lib "kernel32" () As Long Dim SetHp As Integer '''' 定义设定的体力值 Dim SetMp As Integer '''' 定义设定的魔法值 Dim NowHp As Long '''' 定义目前的体力值 Dim NowMp As Long '''' 定义目前的魔法值 Dim MaxHp As Long '''' 定义角色的最高体力值 Dim MaxMp As Long '''' 定义角色的最高魔法值 Dim DiZhi As Long ''''定义内存地址函数
Private Function ncnr(lpADDress As Long) As Integer '''' 声明一些需要的变量 Dim hwnd As Long '''' 储存 FindWindow 函数返回的句柄 Dim pid As Lon [1] [2] 下一页 |