0

hi all i have this great code that i love that will display the kind of processor model and speed like so

RegistryKey Rkey = Registry.LocalMachine;
Rkey = Rkey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
Labelproc.Text = (string)Rkey.GetValue("ProcessorNameString");

and i was wondering if theres a way to do this for the kind of graphics card and the total installed system ram (in separate labels)

4

1 回答 1

0

Rather than reading the registry I'd suggest that you use WMI, specifically Win32_ComputerSystem to find number of CPUs and Win32_Processor to find info about it and Win32_ComputerSystem.TotalPhysicalMemory would give the RAM.
I'm sure there is some way to pick up the graphics card(s) as well (remember that there might be more than one).

Here's an article with some samples for getting out various data:

http://msdn.microsoft.com/en-us/library/aa394587%28VS.85%29.aspx

The samples are in vbscript but it's similar, I think the C# code for getting the RAM would be something like:

ManagementObjectSearcher query = new ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem") ;
ManagementObjectCollection coll = query.Get();
foreach( ManagementObject mo in coll ) 
{
    Console.WriteLine(mo["totalphysicalmemory"].ToString());
}    
于 2010-06-02T10:38:26.113 回答