vb 读取内存的,请帮我看看为什么都是返回0?
Public Function ChaXunDiZhi() As String
Dim nr As Long
Dim dz As Long
Dim i As Long
Dim t1 As String
t1 = ""
Debug.Print "开始了"
For dz = 0 To 999999999
ChaXunNeiCun nr, dz
If nr <> 0 Then
Debug.Print dz & " : " & nr ' & " - " & Chr(nr)
t1 = t1 & dz & " : " & nr & vbCrLf ' & " - " & Chr(nr)
Beep 500, 500
End If
If dz Mod 10000000 = 0 Then
Debug.Print dz
DoEvents
End If
Next
Debug.Print "结束了"
ChaXunDiZhi = t1
End Function
Public Function ChaXunNeiCun(nr As Long, dz As Long) As Boolean
Dim h As Long
Dim sf As Long
If h1_1 = 0 Then
GetWindowThreadProcessId h1, h
If h > 0 Then
h1_1 = OpenProcess(PROCESS_ALL_ACCESS, 0, h)
End If
End If
If h1_1 = 0 Then
ChaXunNeiCun = False
Exit Function
End If
sf = ReadProcessMemory(h1_1, ByVal dz, ByVal VarPtr(nr), 4, 0&)
'sf = ReadProcessMemory(h1_1, dz, nr, 4, 0)
CloseHandle h1_1
If sf <> 0 Then ChaXunNeiCun = True Else ChaXunNeiCun = False
End Function
[解决办法]
h1_1 = 0