Delphi ActiveX
Delphi ActiveX
Get Local Network Adapter Addresses
See more Socket/SSL/TLS Examples
Demonstrates Socket.GetAdaptersAddresses, which populates a JsonObject with information about local network adapters, including IPv4 addresses, IPv6 addresses, and MAC addresses.
Tip: Code to parse the returned JSON can be generated with Chilkat's online tool at https://tools.chilkat.io/jsonParse.
Background. This provides a portable way to enumerate the host's network interfaces and their addresses.
Chilkat Delphi ActiveX Downloads
var
success: Integer;
socket: TChilkatSocket;
json: TChilkatJsonObject;
jsonStr: WideString;
begin
success := 0;
socket := TChilkatSocket.Create(Self);
// Populate a JsonObject with information about the local network adapters, including IPv4 addresses,
// IPv6 addresses, and MAC addresses.
json := TChilkatJsonObject.Create(Self);
success := socket.GetAdaptersAddresses(json.ControlInterface);
if (success = 0) then
begin
Memo1.Lines.Add(socket.LastErrorText);
Exit;
end;
json.EmitCompact := 0;
jsonStr := json.Emit();
Memo1.Lines.Add(jsonStr);
// JSON parsing code for this result can be generated at Chilkat's online tool:
// https://tools.chilkat.io/jsonParse