Fórum MAC da placa de rede #182105
15/09/2003
0
Vqds
Curtir tópico
+ 0Posts
15/09/2003
Bacalhau
arp -a
Para guardar num arquivo
arp -a > arquivo.txt
Gostei + 0
15/09/2003
Vqds
Gostaria de saber se o DELPHI tem este tipo de funcao, com a do IP da paleta indy, pois nao gostaria a ter que recorer a comandos dos para gerar um arquivo e depois ler.
Gostei + 0
31/12/2014
Inforplace Ltda
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;
Begin
try
result := MacAddress;
While pos('-',result) > 0 do
delete(result,pos('-',result),1);
except
result := '';
end;
end;
Gostei + 0
05/01/2015
Luiz Eduardo
uses NB30; function GetAdapterInfo(Lana: Char): String; var Adapter: TAdapterStatus; NCB: TNCB; begin FillChar(NCB, SizeOf(NCB), 0); NCB.ncb_command := Char(NCBRESET); NCB.ncb_lana_num := Lana; if Netbios(@NCB) <> Char(NRC_GOODRET) then begin Result := 'mac not found'; Exit; end; FillChar(NCB, SizeOf(NCB), 0); NCB.ncb_command := Char(NCBASTAT); NCB.ncb_lana_num := Lana; NCB.ncb_callname := '*'; FillChar(Adapter, SizeOf(Adapter), 0); NCB.ncb_buffer := @Adapter; NCB.ncb_length := SizeOf(Adapter); if Netbios(@NCB) <> Char(NRC_GOODRET) then begin Result := 'mac not found'; Exit; end; Result := IntToHex(Byte(Adapter.adapter_address[0]), 2) + '-' + IntToHex(Byte(Adapter.adapter_address[1]), 2) + '-' + IntToHex(Byte(Adapter.adapter_address[2]), 2) + '-' + IntToHex(Byte(Adapter.adapter_address[3]), 2) + '-' + IntToHex(Byte(Adapter.adapter_address[4]), 2) + '-' + IntToHex(Byte(Adapter.adapter_address[5]), 2); end; function GetMACAddress: string; var AdapterList: TLanaEnum; NCB: TNCB; begin FillChar(NCB, SizeOf(NCB), 0); NCB.ncb_command := Char(NCBENUM); NCB.ncb_buffer := @AdapterList; NCB.ncb_length := SizeOf(AdapterList); Netbios(@NCB); if Byte(AdapterList.length) > 0 then Result := GetAdapterInfo(AdapterList.lana[0]) else Result := 'mac not found'; end; procedure TForm1.Button3Click(Sender: TObject); begin ShowMessage(GetMACAddress); end;
Gostei + 0
28/01/2018
Carlos Palacios
No XE10.2 tive que aleterar a variavel LANA par a Ansichar.
se eu não passo nenhum valor, ele volta como MAC nao encontrado.
obrigado.
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)