Created
May 21, 2012 09:54
-
-
Save sunfmin/2761582 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int MACAddr(TCHAR* buf) { | |
IP_ADAPTER_INFO info[16]; | |
DWORD len = sizeof(info); | |
int i = 0; | |
int printed = 0; | |
int return_code = GetAdaptersInfo(info, &len); | |
if (return_code != ERROR_SUCCESS) { | |
return 0; | |
} | |
for(; i<info->AddressLength; i++){ | |
wsprintf(buf, TEXT("%2x"), info->Address[i]); | |
buf += 2; | |
printed += 2; | |
} | |
return printed; | |
} | |
void FillSysinfo(TCHAR* buf){ | |
SYSTEM_INFO s; | |
HW_PROFILE_INFO p; | |
GetCurrentHwProfile(&p); | |
GetSystemInfo(&s); | |
// IsProcessorFeaturePresent | |
int maclen = MACAddr(buf); | |
wsprintf(buf + maclen, TEXT("%s%d%d%u%d%d"), | |
p.szHwProfileGuid, | |
s.wProcessorArchitecture, s.wProcessorRevision, | |
GetLogicalDrives(), | |
GetKeyboardType(0), GetKeyboardType(1), GetKeyboardType(2) | |
); | |
int length = _tcslen(buf); | |
for(int i=0; i<length; i++){ | |
if ( (48 <= buf[i] && buf[i] <= 57) ||//0-9 | |
(65 <= buf[i] && buf[i] <= 90) ||//abc...xyz | |
(97 <= buf[i] && buf[i] <= 122)) //ABC...XYZ | |
{ | |
; | |
} else { | |
buf[i] = '0'; | |
} | |
} | |
return; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment