Click here to Skip to main content
15,900,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how we can check the type of RAM programmatically, that installed RAM is DDR1,DDR2 or DDR3.
Posted

C#
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"]); 
} 



Win32_PhysicalMemory class [^]
 
Share this answer
 
Comments
nika2008 5-Sep-12 2:26am    
using System;using System.Collections.Generic;
using System.Text;
using System.Management;
using System.Management.Instrumentation;
this need to be importet forgot it
Xeshan Ahmed 5-Sep-12 2:32am    
MemoryType is giving you 0 as output.
What is meaning of 0 ??
nika2008 5-Sep-12 2:38am    
this is for 32bit os what u usE?
Xeshan Ahmed 5-Sep-12 2:33am    
i want to know it is DDR1, DDR2 or DDR3
nika2008 5-Sep-12 2:38am    
check the link u have all type u need
string BankLabel;
uint64 Capacity;
string Caption;
string CreationClassName;
uint16 DataWidth;
string Description;
string DeviceLocator;
uint16 FormFactor;
boolean HotSwappable;
datetime InstallDate;
uint16 InterleaveDataDepth;
uint32 InterleavePosition;
string Manufacturer;
uint16 MemoryType;
string Model;
string Name;
string OtherIdentifyingInfo;
string PartNumber;
uint32 PositionInRow;
boolean PoweredOn;
boolean Removable;
boolean Replaceable;
string SerialNumber;
string SKU;
uint32 Speed;
string Status;
string Tag;
uint16 TotalWidth;
uint16 TypeDetail;
string Version;
check what u need from this and just put it on

queryobj["somthink"];

try to install CPU-Z on your computer..it's a freeware..
 
Share this answer
 
Comments
Xeshan Ahmed 5-Sep-12 2:33am    
we need programmatic solution not by using any type of software
[no name] 5-Sep-12 2:34am    
In which language..??
Xeshan Ahmed 5-Sep-12 2:43am    
any .net language, i think its now done by @nika2008
C#
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}", GetMemoryType(Int32.Parse(queryObj["MemoryType"].ToString()))); 

} 

following is method which differentiate between DDR1,DDR2,DDR3 you can check other types on
WMI Physical Memory Types[^]
C#
public string GetMemoryType(int MemoryType)
        {
            switch (MemoryType)
            {
                case 20:
                    return "DDR";
                    break;
                case 21:
                    return "DDR-2";
                    break;
                default:
                    if (MemoryType == 0 || MemoryType > 22)
                        return "DDR-3";
                    else
                        return "Other";
                    break;

            }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900