开发者

label to display graphics card or total system ram through registry possibly?

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 s开发者_运维技巧ystem ram (in separate labels)


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());
}    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜