public class ProcessorInfo
{
private string manufacturer = null;
private UInt32 clockSpeed;
private UInt16 family;
private string version;
private string processorId = null;
public static void ConsoleOutput()
{
ProcessorInfo info = ProcessorInfo.Get();
Console.WriteLine("\nProcessor information:");
Console.WriteLine("----------------------");
Console.WriteLine("Manufacturer: {0}", info.manufacturer);
Console.WriteLine("ClockSpeed: {0}", info.clockSpeed);
Console.WriteLine("Family: {0}", info.family);
Console.WriteLine("Version: {0}", info.version);
Console.WriteLine("ProcessorId: {0}", info.processorId);
Console.WriteLine("\n");
}
public static ProcessorInfo Get()
{
ProcessorInfo output = new ProcessorInfo();
ManagementObjectSearcher searcher = new
ManagementObjectSearcher("SELECT * FROM Win32_Processor");
foreach (ManagementObject wmi_CPU in searcher.Get())
{
output.manufacturer = wmi_CPU["Manufacturer"].ToString();
output.clockSpeed = (UInt32) wmi_CPU["MaxClockSpeed"];
output.family = (UInt16) wmi_CPU["Family"];
output.version = wmi_CPU["Version"].ToString();
output.processorId = wmi_CPU["ProcessorId"].ToString();
break;
}
return output;
}
public string Manufacturer
{
get { return manufacturer; }
}
public UInt32 ClockSpeed
{
get { return clockSpeed; }
}
public UInt16 Family
{
get { return family; }
}
public string Version
{
get { return version; }
}
public string ProcessorId
{
get { return processorId; }
}
}
ti - 25 May 2007 15:01 GMT
Thanks Miroslav.
But I think I need to use GetLogicalProcessorInformation().
Because WMI doesn't give me necessary information as far as I checked.
I'd like to know about the relationship between processor-cores like
below examples.
1. whether core-a and core-b share the same L2-cache.
2. whether core-a, core-b, core-c and core-d are in the same
die(physical processor chip).
I believe one of the best ways is to use
GetLogicalProcessorInformation().
I assume the environment is Vista or future release of windows.
And the necessary platforms are x86, x64 and Itanium, so I guess I
also can't use __cpuid().
Best Regards,
TI