请问一下高手,我用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 LongPrivate 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函数,请问我还该再添加些什么东西?

解决方案 »

  1.   

    呵呵···支持的···你的 标题名称 可能错了···游戏外挂我就做得多了~~~biohazard 4      resident evil 4
    你确定这2个不会有错??
      

  2.   

    lzanze(小泽) :
    撇开biohazard 4      resident evil 4不说,即使特意改成hwnd = FindWindow(vbNullString, "计算器")来检验系统自带的计算器(标题栏名字就是“计算器”,最后的结果还是一样的。
      

  3.   

    aspower_(敬个礼 握个手 大家都素好朋友!):
    能否详细说明哪个参数不对?
    我从网上下载了内存修改器的代码输入VB……引用这一段:
    Dim pHandle As Long
    pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    If (pHandle = 0) Then
    MsgBox "Couldn't get a process handle!"
    Exit Sub
    End If
    运行结果也是提示Couldn't get a process handle
      

  4.   

    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As String) As Long 
    hwndCalc = FindWindow(0&, "计算器") 你用这个搜索下计算器看看可以不呵呵还有不要用or
      

  5.   

    aspower_(敬个礼 握个手 大家都素好朋友!):
    仍是无效。而且本来问题也不在FindWindow(即使用or,也能找到biohazard 4和计算器两个窗口),问题似乎在
    GetWindowThreadProcessId hwnd, pid
    pHandle = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
    ……
    pHandle总是返回0