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
Just turn off the flip using the "flip" flag of the flibAndCodeBytes function when windows 8 or greater.
bool shoulFlipBytes = true;
if(IsWin8OrLater()) shouldFlipBytes = false;
flipAndCodeBytes(buffer,
descrip->SerialNumberOffset,
shouldFlipBytes,
serialNumber);
You can use this to check for windows version:
#include
bool IsWin8OrLater() {
DWORD version = GetVersion();
DWORD major = (DWORD) (LOBYTE(LOWORD(version)));
DWORD minor = (DWORD) (HIBYTE(LOWORD(version)));
return (major > 6) || ((major == 6) && (minor >= 2));
}
According to http://msdn.microsoft.com/en-us/library/ms724832%28VS.85%29.aspx (Thanks to ChrisV Determine if O/S is Windows 7)