开发者

Why this code generates different numbers?

开发者 https://www.devze.com 2022-12-31 04:26 出处:网络
I have this function that creates a unique number for hard-disk and CPU combination. GetVolumeInformation(drv, szNameBuffer, 256, &dwHddUnique, NULL, NULL, NULL, NULL);

I have this function that creates a unique number for hard-disk and CPU combination.

    GetVolumeInformation(drv, szNameBuffer, 256, &dwHddUnique, NULL, NULL, NULL, NULL);

    SYSTEM_INFO si;
    GetSystemInfo(&si);

    dwProcessorUnique = si.dwProcessorType + si.wProcessorArchitecture + si.wProcessorRevision;
    dwUniqueKey = dwProcessorUnique + dwHddUnique;

It returns different numbers if I format my hard-disk and install a new Windows. Any ideas, why?

Thank you.

Edit:

OK, Got it (http://msdn.microsoft.com/en-us/library/aa364993(VS.85).aspx):

This function returns the volume serial number that the operating system assigns when a hard disk is formatted. To programmatically obtain the hard disk's serial number that the manufacturer assigns, use the Windows Management Instrumentation (WMI) Win32_PhysicalMedia property SerialNumber.

I shoul开发者_JAVA百科d do more research before posting my problems online. Sorry to bother you, let's keep this here in case anybody else can need it.


Maybe because when you format your hard disk it generates a new unique UUID for it? (so dwHddUnique would be different)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号