openprocess()为何返回值总为0
请问一下高手,我用VB编写的游戏修改器,在模块里声明了这6个必用的API函数
'寻找窗口
Declare Function FindWindow Lib "user32 " Alias "FindWindowA " (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
'获取窗口ID
Declare Function GetWindowThreadProcessId Lib "user32 " (ByVal hwnd As Long, lpdwProcessId As Long) As Long
'打开进程
Declare Function OpenProcess Lib "kernel32 " (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
'写入内存
Declare Function WriteProcessMemory Lib "kernel32 " (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Long, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
'读取内存
Declare Function ReadProcessMemory Lib "kernel32 " (ByVal hProcess As Any, ByVal lpBaseAddress As Any, ByVal lpBuffer As Long, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
'关闭句柄
Declare Function CloseHandle Lib "kernel32 " (ByVal hObject As Long) As Long
Private Sub mnureadbio4_Click()
在form1中写入代码:
'声明变量
Dim hwnd As Long
Dim pid As Long
Dim pHandle As Long
flagmnureadbio4click = False
'寻找游戏窗口
hwnd = FindWindow(vbNullString, "biohazard 4 ") Or FindWindow(vbNullString, "resident evil 4 ")
If (hwnd = 0) Then
MsgBox "生化未运行 ", , "生化危机系列修改器 "
Exit Sub
Else
'读取进程
GetWindowThreadProcessId hwnd, pid
pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
If (pHandle = 0) Then
MsgBox "生化4未运行 ", , "生化危机系列修改器 "
Exit Sub
Else
flagmnureadbio4click = True
End If
End Sub
结果总是提示“生化4未运行”,也就是说openprocess()那总返回0值。据说win2000以上的系统不直接支持这6个API函数,请问我还该再添加些什么东西?
[解决办法]
调用GetLastError查看错误码
[解决办法]
呵呵···支持的···
你的 标题名称 可能错了···游戏外挂我就做得多了~~~
biohazard 4 resident evil 4
你确定这2个不会有错??
[解决办法]
Declare Function FindWindow Lib "user32 " Alias "FindWindowA " (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long
hwndCalc = FindWindow(0&, "计算器 ")
你用这个搜索下计算器看看可以不
呵呵
还有不要用or