title: WMI hardware, get RAM info
body: <p>I need to retrieve RAM info from both local and remote computers, I am aware of WMI in System.Management and I am using it, but my problem with WMI is that the Win32_PhysicalMemory class has a value that I need called "<strong>MemoryType</strong>", but it always returns 0 or "Unknown".<br>
  <a href="http://msdn.microsoft.com/en-us/library/aa394347%28v=vs.85%29.aspx" rel="nofollow" title="Win32_PhysicalMemory class"><strong>Win32_PhysicalMemory class</strong> (http://msdn.microsoft.com/en-us/library/aa394347%28v=vs.85%29.aspx)</a></p>
  
  <p>I have tried to use Win32_PhysicalMemory from both C# and VBScript on 3 different XP Professional computers with an admin account and got the same 0 or "Unknown" MemoryType value returned. The code I used is simple and short, copy and pasted from a number of sources around the net so I'm sure there aren't major problems with it.</p>
  
  <p>Am I using WMI wrongly or is there a Windows API alternative i can use?<br>
  Remote reports aren't essential.</p>
  
  <p>Specifically I need to count the number of sticks of RAM it has, or can have, the speed, and the type of RAM it uses, DDR2, DDR3, etc., the Win32_PhysicalMemory class gives me all this except the type of RAM.</p>
  
  <pre class="lang-cs prettyprint-override"><code>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"]);
  }
  </code></pre>