首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VB >

vb 读取内存的,请帮小弟我看看为什么都是返回0

2012-01-13 
vb 读取内存的,请帮我看看为什么都是返回0?Public Function ChaXunDiZhi() As StringDim nr As LongDim dz

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关闭了,可是又仍然再使用它.

[解决办法]
既然要用 h1_1 进行是否打开的判断,那么关闭后就应该马上设置
VB code
h1_1 = 0 

热点排行