1个回答
展开全部
应用里添加 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
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询