重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
这么高深的问题,除非你舍得100分以上的悬赏,否则是没人回答的
十多年的安仁网站建设经验,针对设计、前端、开发、售后、文案、推广等六对一服务,响应快,48小时及时工作处理。成都全网营销的优势是能够根据用户设备显示端的尺寸不同,自动调整安仁建站的显示方式,使网站能够适用不同显示终端,在浏览器中调整网站的宽度,无论在任何一种浏览器上浏览网站,都能展现优雅布局与设计,从而大程度地提升浏览体验。成都创新互联从事“安仁网站设计”,“安仁网站推广”以来,每个客户项目都认真落实执行。
总量:My.Computer.Info.TotalPhysicalMemory
可用的:My.Computer .Info .AvailablePhysicalMemory
已使用量=总量-可用的
你是想读取游戏进程吧 这个问题刚开始也 让我郁闷了很久 其实很多 游戏对读取内存做了特殊处理 常规的 调用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
用.ini文件来存储。比如内容是:[UserInfo]UserName=admin读取方式:charachUserName[20];GetPrivateProfileString("UserInfo","UserName",NULL,achUserName,20,"c:\\userInfo.ini");
使用wmi
类“Win32_Processor”中LoadPercentage属性为当前的cpu使用率
示例代码: Private Sub Timer1_Timer()
Dim WMI服务 As Object
Dim 对象 As Object
Dim 子对象 As Object
Dim 电脑名 As String
Dim 刷新 As Long
刷新 = 0
电脑名 = "." '表示本地计算机
Set WMI服务 = GetObject("winmgmts://" 电脑名 "/root/cimv2")
Set 对象 = WMI服务.InstancesOf("Win32_Processor")
Me.CurrentX = 0
Me.CurrentY = 0
For Each 子对象 In 对象
If 刷新 = 0 Then
刷新 = 1
Me.Cls
End If
Me.Print 子对象.Name "[" 子对象.CurrentClockSpeed "Hz] 使用率:" _
子对象.LoadPercentage "%"
Next
End Sub
应用里添加 System.Management
文件前加上
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