IP address lazarus / 38-Networking and Web Programming ---------------------------------------------------------------------- pcurtis · 2022-08-04 12:45 How do I get the IP addresses of all network interfaces on Windows using API. I have tried the attached demo but it doesn't return  IP information. ---------------------------------------------------------------------- marcov · 2022-08-04 12:48 Here it does. Note that afaik it only returns them for active network interfaces, so if you have something configured without a cable in it, it might not show? ---------------------------------------------------------------------- Remy Lebeau · 2022-08-04 17:28 Quote from: pcurtis on August 04, 2022, 02:45:15 pmHow do I get the IP addresses of all network interfaces on Windows using API. I have tried the attached demo but it doesn't return  IP information. Try something more like this instead: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i procedure TfrmMain.RetrieveLocalAdapterInformation;var  pAdapters, pAdapter: PIP_ADAPTER_INFO;  pIPAddress: PIP_ADDR_STRING;  BufLen: DWORD;  Status: DWORD;  strMAC: String;  i: Integer;  strings: TStrings;begin  strings := TStringList.Create;  try    BufLen := 1024*15;    pAdapters := AllocMem(BufLen);     try      repeat        Status := GetAdaptersInfo(pAdapters, BufLen);        if (Status <> ERROR_BUFFER_OVERFLOW) then Break;        ReallocMem(pAdapters, BufLen);      until False;       if (Status = ERROR_SUCCESS) and (BufLen = 0) then        Status := ERROR_NO_DATA;       if (Status <> ERROR_SUCCESS) then      begin        case Status of          ERROR_NOT_SUPPORTED:            strings.Add('GetAdaptersInfo is not supported by the operating ' +                        'system running on the local computer.');          ERROR_NO_DATA:            strings.Add('No network adapter on the local computer.');        else          strings.Add('GetAdaptersInfo failed with error #' + IntToStr(Status));        end;        Exit;      end;       pAdapter := pAdapters;      repeat        Memo1.Lines.Add('');        Memo1.Lines.Add('Description: ------------------------' + string(pAdapter^.Description));        Memo1.Lines.Add('Name: ' + string(pAdapter^.AdapterName));         strMAC := '';        for I := 0 to pAdapter^.AddressLength - 1 do          strMAC := strMAC + '-' + IntToHex(pAdapter^.Address[I], 2);        Delete(strMAC, 1, 1);      Memo1.Lines.Add('MAC address: ' + strMAC);         pIPAddress := @pAdapter^.IpAddressList;        repeat          Memo1.Lines.Add('IP address: ' + string(pIPAddress^.IpAddress.S));          Memo1.Lines.Add('IP subnet mask: ' + string(pIPAddress^.IpMask.S));        pIPAddress := pIPAddress^.Next;        until (pIPAddress = nil);         //pIPAddress := @pAdapter^.GatewayList;        //repeat        //  Memo1.Lines.Add('Gateway: ' + string(pIPAddress^.IpAddress.S));        //  pIPAddress := pIPAddress^.Next;        //until (pIPAddress = nil);         //Memo1.Lines.Add('DHCP enabled: ' + IntToStr(pAdapter^.DhcpEnabled));        //Memo1.Lines.Add('DHCP: ' + pAdapter^.DhcpServer.IpAddress.S);        //Memo1.Lines.Add('Have WINS: ' + BoolToStr(pAdapter^.HaveWins,True));        //Memo1.Lines.Add('Primary WINS: ' + pAdapter^.PrimaryWinsServer.IpAddress.S);         //pIPAddress := @pAdapter^.SecondaryWinsServer;        //repeat        //  Memo1.Lines.Add('Secondary WINS: ' + string(pIPAddress^.IpAddress.S));        //  pIPAddress := pIPAddress^.Next;        //until (pIPAddress = nil);         pAdapter := pAdapter^.Next;      until (pAdapter = nil);    finally      Dispose(pAdapters);    end;  finally    strings.Free;  end;end;  Note that GetAdaptersInfo() has been deprecated since Windows Vista, you should be using GetAdaptersAddresses() instead.