Search code examples
delphiindy

What are the enumerations of tIdIpVersion?


I use delphi seattle whose indy version is 10.6.2.5311. The version of indy reference included in the delphi is 10.1.5.

I try to get ip addresses of ipv4 in the local network.

The enumerations of tIdIpVersion, id_ipv4 and id_ipv6 are not recognized in seattle. I guess they were changed. I can't jump into tIdIpVersion because I use a trial version.

procedure TForm1.FormCreate(Sender: TObject);
var
  _AddressList: TIdStackLocalAddressList;
  _Address: TIdStackLocalAddress;
  i: Integer;
begin
  _AddressList := TIdStackLocalAddressList.Create;

  TIdStack.IncUsage;

  GStack.GetLocalAddressList(_AddressList);

  for i := 0 to _AddressList.Count - 1 do
  begin
    _Address := _AddressList[i];

    if _Address.IPVersion = id_ipv4 then // id_ipv4 is not identified.
    begin
      Memo1.Lines.Add(_Address.IPAddress);
    end;
  end;

  TIdStack.DecUsage;

  _AddressList.Free;
end;

Solution

  • You can find the enumeration in the unit IdGlobal

      TIdIPVersion = (Id_IPv4, Id_IPv6);
    

    You can easily check this yourself, as the Indy source code is publicly available:

    https://svn.atozed.com:444/svn/Indy10/trunk (Username: Indy-Public-RO, password blank)