bnz
asked on
Delphi exe size
If I create a new clean application which uses no extra unit my project is about 16kb, if I include lets say inifiles in uses clause the file growns even when I don't use anything from inifiles.pas.
Why does delphi include code from inifiles when it is unneeded ? Is there a way to remove this unused code ?
Why does delphi include code from inifiles when it is unneeded ? Is there a way to remove this unused code ?
You can make a package. It is very small because is doesn't compile any units. It uses DLLs which are included in the Windows directory. It doesn't work sometimes because a certain DLL may be old...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Shrink the size of your .EXE using the UPX tool... get the latest version from http://upx.sourceforge.net/
hello bnz, you can remove the unneeded Kb by rewriting the units (SysUtils and Classes) and only including the functions and initialization code that you need for your app, but this can take time and requires API knowledge. You could use API and leave out the inifiles unit altogether.
var
IniName: PChar;
CharBuffer: array[0..255] of Char;
IniName := 'C:\App Folder\this.ini';
GetPrivateProfileString(Fo rmPos,'Top ','70', CharBuffer, SizeOf(CharBuffer), IniName);
{GetPrivateProfileString reads the specified String or gets the lpDefault
if there is no string to read}
Top := Str2Int(String(CharBuffer) );
{get the Top and Left for the window position}
GetPrivateProfileString(Fo rmPos,'Lef t','70', CharBuffer, SizeOf(CharBuffer), IniName);
Left := Str2Int(String(CharBuffer) );
procedure ShutDown;
var
WinPlace: TWindowPlacement;
begin
WinPlace.length := SizeOf(TWindowPlacement);
GetWindowPlacement(hNoteHa ndle,@WinP lace);
WritePrivateProfileString( FormPos,'T op',PChar( Int2Str(Wi nPlace.rcN ormalPosit ion.Top)), IniName);
{WritePrivateProfileString writes to an Ini file}
WritePrivateProfileString( FormPos,'L eft',PChar (Int2Str(W inPlace.rc NormalPosi tion.Left) ),IniName) ;
PostQuitMessage(0);
end;
Are you trying to create an app without the Forms unit?
var
IniName: PChar;
CharBuffer: array[0..255] of Char;
IniName := 'C:\App Folder\this.ini';
GetPrivateProfileString(Fo
{GetPrivateProfileString reads the specified String or gets the lpDefault
if there is no string to read}
Top := Str2Int(String(CharBuffer)
{get the Top and Left for the window position}
GetPrivateProfileString(Fo
Left := Str2Int(String(CharBuffer)
procedure ShutDown;
var
WinPlace: TWindowPlacement;
begin
WinPlace.length := SizeOf(TWindowPlacement);
GetWindowPlacement(hNoteHa
WritePrivateProfileString(
{WritePrivateProfileString
WritePrivateProfileString(
PostQuitMessage(0);
end;
Are you trying to create an app without the Forms unit?
If you don't need some units just remove these from uses section.
If you don't know if use some units or not, just remove one by one and try to run the application . If receive error mesages then undo . Do that for all declared units ( but one be one ) .