function my_ip_address:longint;<br>const<br> bufsize=255;<br>var<br> buf: pointer;<br> RemoteHost : PHostEnt; (* No, don't free it! *)<br><br>begin<br> buf:=NIL;<br> try<br> getmem(buf,bufsize);<br> winsock.gethostname(buf,bufsize); (* this one maybe without domain *)<br> RemoteHost:=Winsock.GetHostByName(buf);<br> if RemoteHost=NIL then<br> my_ip_address:=winsock.htonl($07000001) (* 127.0.0.1 *)<br> else<br> my_ip_address:=longint(pointer(RemoteHost^.h_addr_list^)^);<br> finally<br> if buf<>NIL then freemem(buf,bufsize);<br> end;<br> result:=winsock.ntohl(result);<br>end;<br><br>