资讯

精准传达 • 有效沟通

从品牌网站建设到网络营销策划,从策略到执行的一站式服务

vb.net读取内存 vbnet读取内存地址

vb.net获取内存总量

应用里添加 System.Management

10余年的本溪网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整本溪建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。创新互联从事“本溪网站设计”,“本溪网站推广”以来,每个客户项目都认真落实执行。

文件前加上

Imports System.Management

''' summary

''' 获取系统内存大小

''' /summary

''' returns内存大小(单位Byte)/returns

Private shared Function GetPhisicalMemory()As Long

dim searcher = new ManagementObjectSearcher()   '用于查询一些如系统信息的管理对象

searcher.Query = new SelectQuery("Win32_PhysicalMemory ", "", new string() { "Capacity" })'设置查询条件 

dim collection = searcher.Get()   '获取内存容量 

dim em = collection.GetEnumerator()

dim capacity as long= 0

While (em.MoveNext())

dim baseObj = em.Current

If (baseObj.Properties("Capacity").Value IsNot Nothing) Then                    

Try

capacity += long.Parse(baseObj.Properties("Capacity").Value.ToString())

Catch

return 0

End Try

End If 

End While

return capacity

End Function

vb.net 读取内存失败 求高手解答

你是想读取游戏进程吧 这个问题刚开始也 让我郁闷了很久 其实很多 游戏对读取内存做了特殊处理 常规的 调用api打开进程 读取内存 无效可以尝试 用token 直接调用就ok了 返回true说明调用成功下面是详细代码 Public Class ToKen

#Region "常数及结构声明"

Private Const SE_PRIVILEGE_ENABLED As Int32 = 2

Private Const EWX_SHUTDOWN As Int32 = 1

Private Const EWX_REBOOT As Int32 = 2

Private Const EWX_LOGOFF As Int32 = 0

Private Structure LUID_AND_ATTRIBUTES

Public pLuid As LUID

Public Attributes As Integer

End Structure

Private Structure LUID

Dim LowPart As Int32

Dim HighPart As Int32

End Structure

Private Structure TOKEN_PRIVILEGES

Public PrivilegeCount As Integer

Public Privileges As LUID

Public Attributes As Int32

End Structure

#End Region#Region "API声明"

Private Declare Function LookupPrivilegeValue Lib "advapi32.dll" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, ByRef lpLuid As LUID) As Int32

Private Declare Function AdjustTokenPrivileges Lib "advapi32.dll" (ByVal TokenHandle As IntPtr, ByVal DisableAllPrivileges As Int32, ByRef NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Int32, ByRef PreviousState As TOKEN_PRIVILEGES, ByRef ReturnLength As Int32) As Int32

Private Declare Function OpenProcessToken Lib "advapi32.dll" (ByVal ProcessHandle As IntPtr, ByVal DesiredAccess As Integer, ByRef TokenHandle As IntPtr) As Boolean

#End Region

#Region "获取全部权限"

Public Function ToKenPrivileges() As Boolean

Dim hdlTokenHandle As Integer

Dim tmpLuid As LUID

Dim tkp As TOKEN_PRIVILEGES

Dim tkpNewButIgnored As TOKEN_PRIVILEGES

Dim lBufferNeeded As Integer

Dim currentProcess As Process = Process.GetCurrentProcess()

If OpenProcessToken(currentProcess.Handle, HF00FF, hdlTokenHandle) Then

LookupPrivilegeValue("", "SeDebugPrivilege", tmpLuid)

tkp.PrivilegeCount = 1

tkp.Privileges = tmpLuid

tkp.Attributes = SE_PRIVILEGE_ENABLED

Return AdjustTokenPrivileges(hdlTokenHandle, False, tkp, Len(tkpNewButIgnored), tkpNewButIgnored, lBufferNeeded)

End If

End Function

#End Region

End Class

vb.net尝试读取或写入受保护的内存。这通常指示其他内存已损坏

这说明你调用 API 传参存在问题。

首先有没有设置结构体内存对齐?

[StructLayout(LayoutKind.Sequential)] 加了吗?

COLORREF 不要用 Color 代替,用 int 代替

TCHAR cfFaceName[32] 定义为 Byte 数组也可以,带在传参前,必须初始化为 32 个长度


分享名称:vb.net读取内存 vbnet读取内存地址
分享URL:http://www.cdkjz.cn/article/hjcsse.html
多年建站经验

多一份参考,总有益处

联系快上网,免费获得专属《策划方案》及报价

咨询相关问题或预约面谈,可以通过以下方式与我们联系

大客户专线   成都:13518219792   座机:028-86922220