Delphi, How to get all local IPs?

前端 未结 6 1657
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-03 07:47

Any one know a way in delphi get a simple list (eg tstrings) of the local ip address.

I have had a look at the other related question, and cant seem to get my head a

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 08:12

    From Delphi 7 Indy 9 source I find something that solved the problem using GStack. It's a little bit different from previous post.

    function GetLocalIPAddress(List: TStringlist): Integer;
    begin     
      if Assigned(GStack) then
        List.Assign(TStringlist(GStack.LocalAddresses))
      else
      begin
        GStack := GStackClass.Create;
        List.Assing(TStringlist(GStack.LocalAddresses));
        FreeAndNil(GStack);
      end;
    end;
    

    I think this will work with Indy 10 too.

提交回复
热议问题