Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get the own IP Address

Status
Not open for further replies.

Spent

Programmer
Mar 20, 2003
100
BG
Get the own IP Address?




uses
Winsock;

{...}

function getIPs: Tstrings;
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 := TstringList.Create;
Result.Clear;
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
if phe = nil then Exit;
pPtr := PaPInAddr(phe^.h_addr_list);
I := 0;
while pPtr^ <> nil do
begin
Result.Add(inet_ntoa(pptr^^));
Inc(I);
end;
WSACleanup;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines := GetIps;
end;


 
Try that again without 'Process TGML' checked.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top