DelphiFAQ Home Search:

Reducing application EXE size

 

comments3 comments. Current rating: 5 stars (1 votes). Leave comments and/ or rate it.

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;


You don't like the formatting? Check out SourceCoder then!

Comments:

2006-05-25, 14:35:30
fvazquez@gmx.net from Mexico  
rating
I don't understand the variable sPath it's supposed to contain the path of the exe file, but how do I use the
sPath := ExtractFilePath(ParamStr(0));
Please help, cause this is what I need to reduce the size of my application.

Thanks
Francisco
2006-06-15, 05:51:20
Richard at lionhardt.ca from United Kingdom  
ParamStr(0) is full path + name of your executable. What he does there is extracting the path without the exename. if your app is c:\bla bla bla\test.exe then using the 2nd sample you would end up with c:\bla bla bla\
2006-08-31, 08:04:36
anonymous from Netherlands  
This does nt work for Webmodules/IIS dll.

Use ExtractFilePath(GetModuleName(HINSTANCE));

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: