ReadProcessMemory 出998错误~~`哭 大侠救命~

来源:百度知道 编辑:UC知道 时间:2024/06/07 20:49:10
救命啊~~..
Option Explicit
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) 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 WriteProcessMemory 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 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 ReadProcessMemory Lib "kernel32" (ByVal hProcess

handle = FindWindow("扫雷", "扫雷")
这个API的第一个参数是窗口类,应该不会是中文的吧,哈哈,估计就是这里错了,不信你可以在下面加上
msgbox handle
来检验一下看,你这么写应该是0,实际应该是一个不小的数字

你修改一下:
handle = FindWindow(vbnullstring,"扫雷")
if handle = 0 then
msgbox "游戏未启动"
else
msgbox "游戏已启动"
end if