L
landina
Unregistered / Unconfirmed
GUEST, unregistred user!
<br>procedure Tregistercode.getMacAddress(out AValue: OleVariant);<br> var<br> AdapterList: TLanaEnum;<br> NCB: TNCB;<br>begin<br> FillChar(NCB, SizeOf(NCB), 0);<br> NCB.ncb_command := Char(NCBENUM);<br> NCB.ncb_buffer := @AdapterList;<br> NCB.ncb_length := SizeOf(AdapterList);<br> Netbios(@NCB);<br> if Byte(AdapterList.length) > 0 then<br> AValue := GetAdapterInfo(AdapterList.lana[0])<br> else<br> AValue := '应用服务器上未发现网卡!';<br>end;<br><br><br><br><br><br><br><br> function Tregistercode.GetAdapterInfo(Lana: Char): String;<br> var<br> Adapter: TAdapterStatus;<br> NCB: TNCB;<br> begin<br> FillChar(NCB, SizeOf(NCB), 0);<br> NCB.ncb_command := Char(NCBRESET);<br> NCB.ncb_lana_num := Lana;<br> if Netbios(@NCB) <> Char(NRC_GOODRET) then<br> begin<br> Result := 'mac not found';<br> Exit;<br> end;<br><br> FillChar(NCB, SizeOf(NCB), 0);<br> NCB.ncb_command := Char(NCBASTAT);<br>//此处如果为NCB.ncb_command := Char(NCBENUM);在联网和不联网的值不一样。<br> NCB.ncb_lana_num := Lana;<br> NCB.ncb_callname := '*';<br><br> FillChar(Adapter, SizeOf(Adapter), 0);<br> NCB.ncb_buffer := @Adapter;<br> NCB.ncb_length := SizeOf(Adapter);<br> if Netbios(@NCB) <> Char(NRC_GOODRET) then<br> begin<br> Result := 'mac not found';<br> Exit;<br> end;<br> Result :=<br> IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' +<br> IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' +<br> IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' +<br> IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' +<br> IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' +<br> IntToHex(Byte(Adapter.adapter_address[5]), 2);<br> end;