문제

I want to detect the capabilities op CPU's (especially if it is an 32/64 bit CPU)

The machines are running on a 32-bit OS (WinXP) and I want to detect if these machine are capable to get a 64 bit OS installed.

(BTW: At this point I know how to detect the number of cores...)

도움이 되었습니까?

해결책

You can use WMI to get more details about each CPU, the following properties are available in the Win32_Processor class

You can Use the following code to get the value of each property :

ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor");
ManagementObjectCollection cpus = searcher.Get()
foreach (ManagementObject queryObj in cpus)
{
    Console.WriteLine("AddressWidth : {0}", queryObj["AddressWidth"]); //On a 32-bit operating system, the value is 32 and on a 64-bit operating system it is 64.
    Console.WriteLine("DataWidth: {0}", queryObj["DataWidth"]); //On a 32-bit processor, the value is 32 and on a 64-bit processor it is 64
    Console.WriteLine("Architecture: {0}", queryObj["Architecture"]); //Processor architecture used by the platform
}

I'm not sure if the AddressWidth is the correct property that you need to determine if the CPU is capable with 64 bit OS or not

다른 팁

Or if you want to play around with all WMI Classes you could use the WMI Code Creator

I've used it before and it helped me a lot.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top