问题
As part of a machine identification system, I'm looking for the Signature of the Win32_DiskDrive. On two customer's machines now, I've seen this field have a random value. I assume that is due to not having checked the HRESULT in the shipped code.
What would cause a machine to not have a valid signature?
WQL query: SELECT Caption, DeviceID, Signature, TotalSectors FROM Win32_DiskDrive
Update:
This has now been seen on 3 machines, one in China, one in Eastern Europe, and one in Canada. When I say it returns a random value, I mean it returns a different random value every time it is queried. Waiting on a customer to try diskpart and see what it says when the uniqueid is requested.
回答1:
I couldn't find a way to determine that the Signature was null.
My solution was to iterate through the partitions for the disk drive
wstring partionquery= L"ASSOCIATORS of {Win32_DiskDrive.DeviceID='";
partionquery += disk_deviceid;
partionquery += L"'} WHERE AssocClass = Win32_DiskDriveToDiskPartition";
Retrieve the Type value and see if it starts with "GPT" and if so, call DeviceIoControl with IOCTL_DISK_GET_PARTITION_INFO_EX. This provides the GUID signature of the GPT partition.
In my testing, each partition gives the same signature on a disk, and it matches the signature shown as the uniqueid in diskpart.
来源:https://stackoverflow.com/questions/13612067/random-value-for-disk-signature