Main Topics
Browse All TopicsHow i display the IP address of my system to edit1.text using delphi code
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,WinSock, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
Label1: TLabel;
function LocalIP: string; //<--insert this line
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormResize(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function TForm1.LocalIP: string;
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe: PHostEnt;
pptr: PaPInAddr;
Buffer: array [0..63] of char;
i: Integer;
GInitData: TWSADATA;
begin
WSAStartup($101, GInitData);
Result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list
i := 0;
while pptr^[i] <> nil do
begin
result:=StrPas(inet_ntoa(p
Inc(i);
end;
WSACleanup;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption:=LocalIP;
end;
procedure TForm1.Timer1Timer(Sender:
begin
Label1.Caption:=LocalIP;
end;
procedure TForm1.FormResize(Sender: TObject);
begin
Application.Title := Label1.Caption;
end;
end.
This works even under W7 !
However this only gets your local IP.If you are behind a router then its another thing....
Business Accounts
Answer for Membership
by: sedgwickPosted on 2009-11-01 at 05:07:33ID: 25713592
here a function which returns current ip address:
Select allOpen in new window