开发者

Why this code generates different numbers?

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜