View Single Post
  #3  
Old 11-08-2016, 02:47 AM
Rantor777 Rantor777 is offline
Junior Member
 
Join Date: Nov 2016
Location: 127.0.0.1
Posts: 10
Default Method #001

PHP Code:
function GetMACAdressstring
var   
NCBPNCB;   
AdapterPAdapterStatus;   
URetCodePChar;   
RetCodeansichar;   
Iinteger;   
LenumPlanaEnum;   
_SystemIDstring;   
TMPSTRstring
begin   
Result    
:= '';  
 
_SystemID := '';   
Getmem(NCBSizeOf(TNCB));   
Fillchar(NCB^, SizeOf(TNCB), 0);   
Getmem(LenumSizeOf(TLanaEnum));   
Fillchar(Lenum^, SizeOf(TLanaEnum), 0);   
Getmem(AdapterSizeOf(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);   
:= 0;   
repeat     
Fillchar
(NCB^, SizeOf(TNCB), 0);     
Ncb.ncb_command  := chr(NCBRESET);     
Ncb.ncb_lana_num := lenum.lana[i];    
RetCode          := Netbios(Ncb);     
Fillchar(NCB^, SizeOf(TNCB), 0);     
Ncb.ncb_command  := chr(NCBASTAT);     
Ncb.ncb_lana_num := lenum.lana[i];     
// Must be 16     
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 (>= Ord(Lenum.Length)) or (_SystemID <> '00-00-00-00-00-00');   FreeMem(NCB);   
FreeMem(Adapter);   
FreeMem(Lenum);   
GetMacAdress := _SystemID
end

Last edited by Rantor777; 11-08-2016 at 02:49 AM.
Reply With Quote