HDD serial number flipped every 2 bytes in Windows XP, Vista and 7 but not in Windows 8

后端 未结 5 1485
一生所求
一生所求 2021-02-19 05:25

I need to get HDD serial number to use it as a key for licensing a software. I used diskid32 code in this url: http://www.winsim.com/d

5条回答
  •  借酒劲吻你
    2021-02-19 06:04

    For licensing-checking purposes, you really don't care. All you need to know is that some configurations result in flipping, some don't, and it can change during the lifetime of a license.

    So accept both variants:

    string serial = get_serial();
    if (license_check(serial)) {
        licensed = true;
        return;
    }
    serial = swap_bytes(serial);
    if (license_check(serial)) {
        licensed = true;
        return;
    }
    

    (I see Raymond suggested this in a comment)

    No fragile OS check, no worries about whether it failed to flip right when the user applied for the license. Just happy users.

提交回复
热议问题