谢谢hanpengshan_00的回答,从我原来的问题来看你的回答应该是有用的,现在我自己也找到了一个标准答案:{$HINTS OFF},这个可行。
但是:我的代码其实是网上找的获取MAC的,我对于NETBIOS也不太熟悉,当时没看仔细,现在仔细一看,RetCode其实是用到了的(if语句中,虽然没有用它来赋值),我觉得根本就不应该出现这个警告啊!
所以现在的问题变成了为什么会有这个警告?
代码如下:
function GetMACAdress:string;
var
NCB
NCB;
Adapter
AdapterStatus;
RetCode:char;
I:integer;
Lenum
lanaEnum;
_SystemID:string;
begin
Result:='';
_SystemID:='';
Getmem(NCB,SizeOf(TNCB));
Fillchar(NCB^,SizeOf(TNCB),0);
Getmem(Lenum,SizeOf(TLanaEnum));
Fillchar(Lenum^,SizeOf(TLanaEnum),0);
Getmem(Adapter,SizeOf(TAdapterStatus));
Fillchar(Adapter^,SizeOf(TAdapterStatus),0);
Lenum.Length:=chr(0);
NCB.ncb_command:=chr(NCBENUM);
NCB.ncb_buffer:=Pointer(Lenum);
NCB.ncb_length:=SizeOf(Lenum);
RetCode:=Netbios(NCB);
i:=0;
repeat
Fillchar(NCB^,SizeOf(TNCB),0);
Ncb.ncb_command:=chr(NCBRESET);
Ncb.ncb_lana_num:=lenum.lana
;
RetCode:=Netbios(Ncb);
Fillchar(NCB^,SizeOf(TNCB),0);
Ncb.ncb_command:=chr(NCBASTAT);
Ncb.ncb_lana_num:=lenum.lana;
// Must be 16
StrPCopy(NCB.ncb_callname,'*');
Ncb.ncb_buffer:=Pointer(Adapter);
Ncb.ncb_length:=SizeOf(TAdapterStatus);
RetCode:=Netbios(Ncb);
//---- calc _systemId from mac-address[2-5] XOR mac-address[1]...
if (RetCode=chr(0)) or (RetCode=chr(6)) then
begin
_SystemId:=IntToHex(Ord(Adapter.adapter_address[0]),2)+'-'+
IntToHex(Ord(Adapter.adapter_address[1]),2)+'-'+
IntToHex(Ord(Adapter.adapter_address[2]),2)+'-'+
IntToHex(Ord(Adapter.adapter_address[3]),2)+'-'+
IntToHex(Ord(Adapter.adapter_address[4]),2)+'-'+
IntToHex(Ord(Adapter.adapter_address[5]),2);
end;
Inc(i);
until (I>=Ord(Lenum.Length)) or (_SystemID<>'00-00-00-00-00-00');
FreeMem(NCB);
FreeMem(Adapter);
FreeMem(Lenum);
GetMacAdress:=_SystemID;
end;