Mega Code Archive

 
Categories / Delphi / Examples
 

Reducing application exe size

In a small project I tried to reduce the application's EXE size. It seemed that I needed to include unit Forms because I needed the application's startup directory. I then remembered that ParamStr(0) contains the same information as Application.ExeName and my EXE file shrank from 290kB to 43kB. After using UPX it now has a size of only 22kB! // this version needs unit Forms uses Forms; begin sPath := ExtractFilePath(Application.ExeName); end; // this version does not! begin sPath := ExtractFilePath(ParamStr(0)); end;