유돌이

calendar

1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31

Notice

2019. 10. 2. 11:39 델파이

// Call CoCreateGuid. The last six bytes are equal to the mac address of
// the Ethernet card. (Note that if you have more than one NIC in your
// computer, you'll get the mac address of one of them, but you can't
// easily control which one.)

// Sneeky... I like it! This will work quite neatly on systems without an
// ethernet card as well. AFAIK this part of the GUID is constant even if you
// only have PPP or even no-networking installed. A useful source of machine
// unique IDs...makes you wonder what the fuss about the PIII ID was about(not
// that I think it's a good idea ;)

// Tip: 델파이 IDE에서 Ctrl-Shift-G 를 눌러보세요...
// GUID가 생성 되는데 뒤에 6바이트(2자리씩 12글자) 는 네트워크 환경이
// 있다면 mac-address 와 같습니다
// PPP or even no-networking

function GetNicAddr: AnsiString;
const
  GUID_MAX = 72;
var
  guid: TGuid;
  buf: array[0..GUID_MAX] of WideChar;
begin
  CoCreateGuid(@guid);
  StringFromGUID2(guid, buf, GUID_MAX);
  Result := Copy(WideCharToString(buf),26,12);
end;

posted by 유돌이