Mega Code Archive

 
Categories / Delphi / String
 

IP to string

Title: IP to string Question: How to convert and number to dotted IP notation. Answer: (* takes an ip address or mask in numeric format and converts it to the standard dotted notation string *) function IPtoStr(IP: LongWord): String; begin Result := Format('%d.%d.%d.%d', [ (IP and $ff000000) shr 24, (IP and $00ff0000) shr 16, (IP and $0000ff00) shr 8, (IP and $000000ff) shr 0 ]); end;