How do I Get My Own IP Address?

Posted December 15th @ 4:20 pm by m3Rlin

If you ever needed your own IP address then here it is the code. Please note that in certain situations you may have more than 1 IP address.

uses
Winsock;

function ReadIPs: TStrings;
type
TaPInAddr = array[0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
Buffer: array[0..63] of Char;
iI: Integer;
PPtr: PaPInAddr;
pHE: [...]

How to Resolve a Host Name

Posted December 15th @ 1:10 pm by m3Rlin

Ever needed to convert a host name to an IP number? There is no direct routine available in Delphi for this but we can always code our way through
Here’s the code with error handling:

uses
Winsock;

// The IP number will be returned in string format in the sIP parameter
function HostToIP(sHost: string; var sIP: string): [...]