获取WMI未返回的系统信息 - C#

时间:2017-01-23 20:46:56

标签: c#

我正在尝试编写一个返回一些系统信息的程序。我在C#中使用WMI,但它似乎无法返回所需的所有信息。

例如,我需要系统Ram信息,这是WMI返回的内容:

enter image description here

以及其他程序返回的内容:

enter image description here

WMI无法返回“制造”或“MemoryType”,那么我如何保留此类信息?

1 个答案:

答案 0 :(得分:0)

试试这段代码:

 ConnectionOptions connection = new ConnectionOptions();
 connection.Impersonation = ImpersonationLevel.Impersonate;
 ManagementScope scope = new ManagementScope("\\root\\CIMV2", connection); 
 scope.Connect(); 
 ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_PhysicalMemory");
 ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
 foreach (ManagementObject queryObj in searcher.Get()) 
 { 
 Console.WriteLine("-----------------------------------");
   foreach (PropertyData data in queryObj.Properties)
    Console.WriteLine(data.Name + "\t" + data.Value); 
 }