在VB读取内存数据中读不出数据返回总是为0 代码如下 '通用申明 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 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 CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long Private Const PROCESS_ALL_ACCESS As Long = &H1F0FFF Private Sub Command1_Click() Dim hwnd As Long '存找到的窗口句柄 Dim pid As Long '存进程pid Dim pHandle As Long '存进程句柄 Dim str As Long '存返回数据 hwnd = FindWindow(vbNullString, "QQ欢乐斗牛") If hwnd = 0 Then MsgBox "not find" '找到窗口 Else MsgBox "find" '没找到窗口 End If GetWindowThreadProcessId hwnd, pid MsgBox pid pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) If (pHandle = 0) Then MsgBox "can't open" '进程句柄打开失败 Else MsgBox "can open" '进程句柄打开成功 End If ReadProcessMemory pHandle, &H400000, str, 2, 0& '读取数据 MsgBox str CloseHandle hProcess End Sub