Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get the cpu information in .net?

Tags:

c#

.net

vb.net

like whether it is pentium or AMD etc.

like image 870
suhair Avatar asked Dec 04 '08 12:12

suhair


2 Answers

Please note that this is from VS2003:

using(ManagementObjectSearcher win32Proc = new ManagementObjectSearcher("select * from Win32_Processor"),         
    win32CompSys = new ManagementObjectSearcher("select * from Win32_ComputerSystem"),
        win32Memory = new ManagementObjectSearcher("select * from Win32_PhysicalMemory"))
            {
                foreach (ManagementObject obj in win32Proc.Get())
                {
                    clockSpeed = obj["CurrentClockSpeed"].ToString();
                    procName = obj["Name"].ToString();
                    manufacturer = obj["Manufacturer"].ToString();
                    version = obj["Version"].ToString();
                }
like image 170
WACM161 Avatar answered Nov 04 '22 19:11

WACM161


The System.Management Namespace Provides access to a rich set of management information and management events about the system, devices, and applications instrumented to the Windows Management Instrumentation (WMI) infrastructure.

The Win32 Processor WMI class represents a device that can interpret a sequence of instructions on a computer running on a Windows operating system. On a multiprocessor computer, one instance of the Win32_Processor class exists for each processor. The class includes a Processor family type field, encoding things like AMD Opteron Processor Family.

An example of C# issuing WMI query is at the end of the page.

like image 39
gimel Avatar answered Nov 04 '22 17:11

gimel