为什么取不到内存值?

angel725 2007-03-04 02:34:50
Public Class Form1
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal hwnd As String, ByVal lpText As String) As Integer
Public Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Integer, ByRef lpdwProcessId As Integer) As Integer
Public Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Integer, ByVal bInheritHandle As Integer, ByVal dwProcessId As Integer) As Integer
Public Const PROCESS_ALL_ACCESS = &H1F0FFF
Public Declare Function ReadProcessMemory Lib "kernel32.dll" ( _
ByVal hProcess As Integer, _
ByVal lpBaseAddress As Integer, _
ByRef lpBuffer() As Byte, _
ByVal nSize As Integer, _
ByRef lpNumberOfBytesWritten As Integer) As Integer
Public Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Integer) As Integer


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim jb As Integer
Dim pid As Integer
Dim hProcess As Integer
Dim bufferr(10) As Byte
Dim readnumber As Integer
jb = FindWindow("Sword3 Class", Nothing)
GetWindowThreadProcessId(jb, pid)
hProcess = OpenProcess(PROCESS_ALL_ACCESS, 0, pid)
ReadProcessMemory(hProcess, &HC0890C0, bufferr, bufferr.Length, readnumber)
TextBox1.Text = System.Text.Encoding.Default.GetString(bufferr)//错在这,提示“数组不能为空”

我在 局部变量 里看到,bufferr的值为Nothing,
为什么??
...全文
243 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
angel725 2007-03-07
  • 打赏
  • 举报
回复
hProcess 有值
Red_angelX 2007-03-07
  • 打赏
  • 举报
回复
你的hProcess 能取到值么?
GetWindowThreadProcessId(jb, pid)
这因该是ref pid
non_smoker 2007-03-06
  • 打赏
  • 举报
回复
Dim totalPhysicalMemmory As ULong
totalPhysicalMemmory = My.Computer.Info.TotalPhysicalMemory()
这样能取到你当前系统的内存值
angel725 2007-03-05
  • 打赏
  • 举报
回复
没人教我

16,556

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧