//uses Nb30
procedure TForm1.Button1Click(Sender: TObject);
var
NCB: PNCB;
Adapter: PAdapterStatus;
URetCode: PAnsiChar;
RetCode: Ansichar;
I: Integer;
Lenum: PlanaEnum;
_SystemID: string;
TMPSTR: string;
s: TStringBuilder;
begin
_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);
try
s := TStringBuilder.Create;
I := 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);
s.AppendLine(_SystemID);
end;
inc(I);
until (I >= Ord(Lenum.length));
ShowMessage(s.ToString);
finally
FreeMem(NCB);
FreeMem(Adapter);
FreeMem(Lenum);
end;
end;
Gostou? Deixe seu comentário... Convido você a seguir meu blog, sua presença é bem vinda!【ツ】
Nenhum comentário:
Postar um comentário