Mega Code Archive

 
Categories / Delphi / LAN Web TCP
 

Only 16K for getting IP !!!

Title: Only 16K for getting IP !!! Question: I found an application (20K) on a magazine that discovers the machine IP and in the article was written that it's hard to reduce the size of a so complex application... just compile this: Answer: Put this code into a Console Application: Program MyIP; {$APPTYPE CONSOLE} Uses WinSock; Var wsaData : TWSAData; Begin WSAStartup( 257, wsaData ); WriteLn( 'Host: ', GetHostByName( NIL )^.h_name ); Write ( 'IP : ', iNet_ntoa( PInAddr( GetHostByName( NIL )^.h_addr_list^ )^ ) ); WSACleanup; End. Then compile it. The resulting EXE file will be 16.834 bytes. And if you compress it with tools like UPX 1.07w, it will be reduced by 59%, resulting EXE files will be only 9.728 bytes !!! (The correct file size for the competition is 16.384) Can anyone do better?