WMI, get information about RAM

I need to get RAM information from local and remote computers, I know about WMI in System.Management, and I use it, but my problem with WMI is that the Win32_PhysicalMemory class has a value that I need to call " MemoryType ", but it always returns 0 or "Unknown."
Win32_PhysicalMemory Class (http://msdn.microsoft.com/en-us/library/aa394347%28v=vs.85%29.aspx)

I tried using Win32_PhysicalMemory from both C # and VBScript on three different XP Professional computers with an administrator account and got the same 0 or "Unknown" MemoryType value. The code I used is simple and short, copied and pasted from several sources over the network, so I'm sure there are no serious problems with it.

Am I using WMI incorrectly or is there an alternative to the Windows API that I can use?
Deleted reports are not material.

In particular, I need to count the number of RAM sticks that it has or can have, the speed and type of RAM used, DDR2, DDR3, etc., the Win32_PhysicalMemory class gives me all this except the type of RAM.

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())
{
    System.Diagnostics.Debug.WriteLine("-----------------------------------");
    System.Diagnostics.Debug.WriteLine("Capacity: {0}", queryObj["Capacity"]);
    System.Diagnostics.Debug.WriteLine("MemoryType: {0}", queryObj["MemoryType"]);
}
+2
1

kb, , SMBIOS ( WMI) . -, . , Windows Server 2003, Windows 7 x64.

, , WMI, SMBIOS. , , , .

+3

Source: https://habr.com/ru/post/1542143/


All Articles