如果是获得本机的,Delphi 7下,加入IdIPWatch:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, IdBaseComponent, IdComponent, IdIPWatch, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
IdIPWatch1: TIdIPWatch;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Add(IdIPWatch1.LocalIP);
Memo1.Lines.Add(IdIPWatch1.LocalName);
end;
end.