可能重复:
Getting Machine’s MAC Address — Good Solution?
How do I get the MAC address of a network card using Delphi?如何在Windows7中获取MAC地址?
我使用MAC地址作为硬件ID为保护(ofcourse我已经加密了这个数据) 我使用下面的代码来获取MAC用户电脑上的地址
function MacAddress: string;
var
Lib: Cardinal;
Func: function(GUID: PGUID): Longint; stdcall;
GUID1, GUID2: TGUID;
begin
Result := '';
Lib := LoadLibrary('rpcrt4.dll');
if Lib <> 0 then
begin
@Func := GetProcAddress(Lib, 'UuidCreateSequential');
if Assigned(Func) then
begin
if (Func(@GUID1) = 0) and
(Func(@GUID2) = 0) and
(GUID1.D4[2] = GUID2.D4[2]) and
(GUID1.D4[3] = GUID2.D4[3]) and
(GUID1.D4[4] = GUID2.D4[4]) and
(GUID1.D4[5] = GUID2.D4[5]) and
(GUID1.D4[6] = GUID2.D4[6]) and
(GUID1.D4[7] = GUID2.D4[7]) then
begin
Result :=
IntToHex(GUID1.D4[2], 2) + '-' +
IntToHex(GUID1.D4[3], 2) + '-' +
IntToHex(GUID1.D4[4], 2) + '-' +
IntToHex(GUID1.D4[5], 2) + '-' +
IntToHex(GUID1.D4[6], 2) + '-' +
IntToHex(GUID1.D4[7], 2);
end;
end;
end;
end;
上面的代码工作完全在Windows XP 但其在Windows7给予不同的值,该值每改变后的计算机resratred :( 有越来越MAC地址的任何机会,这就是固定的时间(除非用户改变了他的MAC地址) 还是有在所有操作系统上修改常量数据的好代码?
在此先感谢
什么让您认为[此代码](http://msdn.microsoft.com/en-us/library/aa379322%28VS.85%29.aspx)检索您的计算机的MAC地址? – 2010-07-17 04:08:47
确认!该功能不返回MAC地址。它返回的值有时恰好包含MAC地址。 – Gabe 2010-07-17 05:04:33