在老毛子的文章里看到的获取本地ip的方法。实现蛮简单。没找到多少关于idStack相关的说明,有空再去外网溜达看看。先记录下。

program 获取本地ip;

{$APPTYPE CONSOLE}

{$R *.res}

uses
 IdStack;

function GetIPLocal: string;
begin
  TIdStack.IncUsage;
  try
    Result := GStack.LocalAddress;
  finally
    TIdStack.DecUsage;
  end;
end;

begin
  writeln(GetIPLocal);
  readln;
end.