We help IT Professionals succeed at work.

How can I get my computer IP Address?

Faruk Onder Yerli
on
Thank you for your help !!!
Comment
Watch Question

Software Developer
CERTIFIED EXPERT
Commented:
uses winsock;

function 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(pptr^[I]^));
      Inc(I);
    end;
    WSACleanup;
end;



procedure TForm1.Button1Click(Sender: TObject);

begin
  ShowMessage(LocalIp);
end;

Explore More ContentExplore courses, solutions, and other research materials related to this topic.