Posts

Showing posts with the label IP Address

How to get local IP Address in Delphi

Many time we need to check for local system IP address where our application is running.  And here I have explained several ways to get local IP Address in Delphi.  I have used Delphi Tokyo for the examples so some examples may not execute in old Delphi versions. So lets check the codes... 1. Using Winsock Delphi unit Winsock Unit is a wrapper to Windows Sockets API. This API is generally used to implement client server applications. uses     Winsock; ....... function GetLocalIP: string; type   TaPInAddr = array [0..10] of PInAddr;   PaPInAddr = ^TaPInAddr; var   phe: PHostEnt;   pptr: PaPInAddr;   Buffer: array [0..63] of Ansichar;   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);  ...