On Fri, 10 Sep 2021, Sven Barth via fpc-pascal wrote:
Bo Berglund via fpc-pascal <fpc-pascal@lists.freepascal.org> schrieb am
Fr., 10. Sep. 2021, 09:41:
Is there a way to enumerate the active adapters on a Windows computer with
their
IPv4 and MAC addresses?
There is an API for that, but I don't remember that right now.
Windows:
uses {$IFDEF MSWINDOWS}Windows, WinSock,{$ENDIF}
type
pu_long = ^U_long;
var
HostEnt : PHostEnt;
InAddr : winsock.TInAddr;
namebuf : Array[0..255] of ansichar;
GinitData: TWSAData;
begin
Result:='';
WSAStartup($101, GInitData);
Try
GetHostName(namebuf,sizeof(namebuf));
HostEnt := gethostbyname(namebuf);
if (HostEnt<>Nil) then
begin
InAddr.S_addr := u_long(pu_long(HostEnt^.h_addr_list^)^);
Result := inet_ntoa(InAddr);
end;
Finally
WSACleanup;
End;
end;
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal