当前位置:编程学习 > VB >>

vb 读取内存+IF 哪错了?高手指点下

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, lpBaseAddress As Any, lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long

dim Value as long 

Private Sub Timer8_Timer() 
    hwnd1 = FindWindow(vbNullString, "海之乐章 ") 
    GetWindowThreadProcessId hwnd1, pid 
    pHandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid) 
    ReadProcessMemory pHandle, &H316040B, Value, 4, 0& 
    CloseHandle pHandle 
If Value = 1127812301 Then 
MsgBox "成功" 
Else 
MsgBox "失败" 
End If 
End Sub

为什么是失败呢? --------------------编程问答-------------------- (1)检查handle pid正确否
(2)用http://download.csdn.net/source/1859731 这个工具看一下 --------------------编程问答-------------------- Value 如果是 long 的话,只能表示 -21亿~21亿内的整数,1127812301太大了。 --------------------编程问答-------------------- 是不是高低字节的问题? --------------------编程问答-------------------- 一个是取的地方,一个是存的地方,永远不可能"成功" --------------------编程问答-------------------- 请参考MSDN中例子pwalk
补充:VB ,  API
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,