Foxtable(狐表)用户栏目专家坐堂 → [求助]请问下读取内存信息报错是什么原因呢


  共有2817人关注过本帖树形打印复制链接

主题:[求助]请问下读取内存信息报错是什么原因呢

帅哥哟,离线,有人找我吗?
81538475
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1302 积分:10502 威望:0 精华:1 注册:2018/1/20 12:40:00
[求助]请问下读取内存信息报错是什么原因呢  发帖心情 Post By:2019/11/12 12:35:00 [只看该作者]

Dim searcher As System.Management.ManagementObjectSearcher = New System.Management.ManagementObjectSearcher()
searcher.Query = New System.Management.SelectQuery(WindowsAPIType.Win32_PhysicalMemory.ToString(), "", New String() {WindowsAPIKeys.Capacity.ToString()})
Dim collection As System.Management.ManagementObjectCollection = searcher.[Get]()
Dim em As System.Management.ManagementObjectCollection.ManagementObjectEnumerator = collection.GetEnumerator()
Dim capacity As Long = 0
Dim i As Integer =0
Dim all2 As String
For Each mo As object In moc
    capacity =  Long.Parse(mo.Properties(WindowsAPIKeys.Capacity.ToString()).Value.ToString())
    i=i+1
 
    For i2 As Integer = 1 To i
    Dim ddr As String =""
    If mo.Properties("SMBIOSMemoryType").Value.ToString()  = 26 Then
     ddr = "DDR4"
    Else
     ddr=mo.Properties("SMBIOSMemoryType").Value.ToString()
    End If
        msgbox("内存" & I & ": " & "  "& capacity/1024/1024/1024 & "GB")
        ALL2 = "内存" & I & ": " & mo.Properties("Manufacturer").Value.ToString() & " " &  mo.Properties("speed").Value.ToString() &  " 参数:" & capacity/1024/1024/1024 & "GB" & "|"

Next
Next
下面是搜集的报错信息

Not found 
   在 Microsoft.VisualBasic.CompilerServices.Symbols.Container.InvokeMethod(Method TargetProcedure, Object[] Arguments, Boolean[] CopyBack, BindingFlags Flags)
   在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.CallMethod(Container BaseReference, String MethodName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack, BindingFlags InvocationFlags, Boolean ReportErrors, ResolutionFailure& Failure)
   在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.InternalLateIndexGet(Object Instance, Object[] Arguments, String[] ArgumentNames, Boolean ReportErrors, ResolutionFailure& Failure, Boolean[] CopyBack)
   在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.ObjectLateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
   在 Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
   在 UserCode.AU0uMyq1TH4xAAWIK(ControlEventArgs e)



 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/12 13:44:00 [只看该作者]

没有WindowsAPIType这种类型,抄代码抄完整

 回到顶部
帅哥哟,离线,有人找我吗?
81538475
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:六尾狐 帖子:1302 积分:10502 威望:0 精华:1 注册:2018/1/20 12:40:00
  发帖心情 Post By:2019/11/12 14:04:00 [只看该作者]

Public Enum WindowsAPIType
Win32_PhysicalMemory
Win32_Processor
win32_DiskDrive
Win32_ComputerSystemProduct
Win32_DesktopMonitor
Win32_VideoController
Win32_OperatingSystem
End Enum
忘记贴全局变量了

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:110574 积分:562760 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/11/12 14:32:00 [只看该作者]

代码不完整,无法测试

 回到顶部