MCPcopy Create free account
hub / github.com/cinience/RedisStudio / GetUniqueMachineID

Method GetUniqueMachineID

RedisStudio/Base/Util.cpp:46–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46std::string Util::GetUniqueMachineID()
47{
48 BYTE szSystemInfo[4096] = {0};
49 UINT uSystemInfoLen = 0;
50 UINT uErrorCode = 0;
51 IP_ADAPTER_INFO iai;
52 ULONG uSize = 0;
53 std::string nicID ;
54 DWORD dwResult = GetAdaptersInfo( &iai, &uSize );
55 if( dwResult != ERROR_BUFFER_OVERFLOW )
56 {
57 return nicID;
58 }
59 IP_ADAPTER_INFO* piai = ( IP_ADAPTER_INFO* )HeapAlloc( GetProcessHeap(), 0, uSize );
60 if( piai == NULL )
61 {
62 return nicID;
63 }
64 dwResult = GetAdaptersInfo( piai, &uSize );
65 if(ERROR_SUCCESS == dwResult)
66 {
67 IP_ADAPTER_INFO* piai2 = piai;
68 while( piai2 != NULL && ( uSystemInfoLen + piai2->AddressLength ) < 4096U )
69 {
70 CopyMemory( szSystemInfo + uSystemInfoLen, piai2->Address, piai2->AddressLength );
71 uSystemInfoLen += piai2->AddressLength;
72 piai2 = piai2->Next;
73 }
74 }
75 HeapFree( GetProcessHeap(), 0, piai);
76 char buf[124] = {0};
77 for (UINT idx = 0; idx < uSystemInfoLen; ++idx)
78 {
79 memset(buf, 0 , sizeof(buf));
80 sprintf(buf, "%02X",szSystemInfo[idx]);
81 nicID += buf;
82 }
83 return nicID;
84}
85
86} // namespace Base

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected