ErikPhilips
asked on
How to get a list of Local Ip Address
I noticed that when i use the Indy Component IdTCPServer, when i click bindings, there is a combo box with a list of local Ip Addresses. How would I go about getting that list?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, that should help other people on EE with the same question. (Funny I didn't find a question like it on EE). I was looking for the INDY approach, but its good to know there is more then 1 answer.
Glad to have helped you :)
BTW a suggestion for your next Indy needs: in program files\borland\delphiX\sour ce\indy there are the indy source files...
sometimes seems to be hard to find Indy solutions even by googling or surfing the Indy project Web site too, so the best way is to find solutions looking directly the source code....
F68 ;-)
BTW a suggestion for your next Indy needs: in program files\borland\delphiX\sour
sometimes seems to be hard to find Indy solutions even by googling or surfing the Indy project Web site too, so the best way is to find solutions looking directly the source code....
F68 ;-)
thank for you
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^[I] <> nil do
begin
Result.Add(inet_ntoa(pptr^
Inc(I);
end;
WSACleanup;
end;
procedure TForm1.Button1Click(Sender
begin
Memo1.Lines := GetIps;
end;