I have the same result, too. You just don't have to dereference property value (you do it by calling the method
ToString
in its instance), because the value of the property can be null, legitimately. At least just check for null.
Your approach is not quite correct. Management documentation is good, but it should be confirmed with what runtime gives you.
ManagementObject
provides some
reflective interface: it tells you what properties are available. Use
System.Management.ManagementObject.Properties
:
http://msdn.microsoft.com/en-us/library/system.management.managementbaseobject.properties.aspx[
^].
This way, you can learn what are the available properties and find them all. For example:
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Processor");
ManagementObjectCollection items = searcher.Get();
foreach (ManagementObject item in items) {
foreach (PropertyData property in item.Properties)
Console.WriteLine("{0}: {1}", property.Name, item[property.Name]);
}
Output it to see what you have. Unique ID is null, yes, but you will see that you can use "ProcessorId", "Name", … You can use other system components for identification, such as HD unique ID…
—SA