mmilan
asked on
Make program shorter...
People can someboduy help me?
Are there any way to make EXE program I compile with Delphi 4.0 as short as possable? How much short I can make it?
Thank's
Are there any way to make EXE program I compile with Delphi 4.0 as short as possable? How much short I can make it?
Thank's
you definitely SHOULD do turn off the compile with debug information. This can really bloat an otherwise slim application. Also, if you are using any resources, such as bitmaps,wav's etc... you might want to look at compiling them separately as resource files. This way they don't bog down the application when not being used.
jordan russel wrote a strip relocator program the takes a few kb off.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok, here you are points but can yo explain in much better?
when you create new application try to set Application type to 'console' (no forms at all! ) remove all units from 'uses', make empty code and compile, look at .EXE size, you will get 16kb or around this.
If you really need a window with controls or something you may create one through API calls, something like this:
Function CreateScreenSaverWindow(Wi dth,Height : Integer;
ParentWindow : hWnd) : hWnd;
Var WC : TWndClass;
Begin
With WC do Begin
Style := cs_ParentDC;
lpfnWndProc := @PreviewWndProc;
cbClsExtra := 0; cbWndExtra := 0; hIcon := 0; hCursor := 0;
hbrBackground := 0; lpszMenuName := nil;
lpszClassName := 'MyDelphiScreenSaverClass' ;
hInstance := System.hInstance;
end;
RegisterClass(WC);
If (ParentWindow 0) Then
Result := CreateWindow('MyDelphiScre enSaverCla ss','MySav er',
ws_Child Or ws_Visible or ws_Disabled,0,0,
Width,Height,ParentWindow, 0,hInstanc e,nil)
Else Begin
Result := CreateWindow('MyDelphiScre enSaverCla ss','MySav er',
ws_Visible or ws_Popup,0,0,Width,Height, 0,0,hInstance,nil);
SetWindowPos(Result,hwnd_T opMost,0,0 ,0,0,swp_N oMove or swp_NoSize or swp_NoRedraw);
End;
PreviewWindow := Result;
End;
for window data you can use Resource Workshop (borland pascal part), your data will be in .RC file like this
SaverSettingsDlg DIALOG 70, 130, 166, 75
STYLE WS_POPUP | WS_DLGFRAME | WS_SYSMENU
CAPTION "Settings for Boxes"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK", 5, 115, 6, 46, 16
PUSHBUTTON "Cancel", 6, 115, 28, 46, 16
CTEXT "Box &Color:", 3, 2, 30, 39, 9
COMBOBOX 4, 4, 40, 104, 50, CBS_DROPDOWNLIST | CBS_HASSTRINGS
CTEXT "Box &Type:", 1, 4, 3, 36, 9
COMBOBOX 2, 5, 12, 103, 50, CBS_DROPDOWNLIST | CBS_HASSTRINGS
LTEXT "Boxes Screen Saver for Win32 Copyright (c) 1996 Jani
Järvinen.", 7, 4, 57, 103, 16,
WS_CHILD | WS_VISIBLE | WS_GROUP
END
are you really need this ? you save A LOT time using VCL, is the size really so critical ? what is the application is this ?
If you really need a window with controls or something you may create one through API calls, something like this:
Function CreateScreenSaverWindow(Wi
ParentWindow : hWnd) : hWnd;
Var WC : TWndClass;
Begin
With WC do Begin
Style := cs_ParentDC;
lpfnWndProc := @PreviewWndProc;
cbClsExtra := 0; cbWndExtra := 0; hIcon := 0; hCursor := 0;
hbrBackground := 0; lpszMenuName := nil;
lpszClassName := 'MyDelphiScreenSaverClass'
hInstance := System.hInstance;
end;
RegisterClass(WC);
If (ParentWindow 0) Then
Result := CreateWindow('MyDelphiScre
ws_Child Or ws_Visible or ws_Disabled,0,0,
Width,Height,ParentWindow,
Else Begin
Result := CreateWindow('MyDelphiScre
ws_Visible or ws_Popup,0,0,Width,Height,
SetWindowPos(Result,hwnd_T
End;
PreviewWindow := Result;
End;
for window data you can use Resource Workshop (borland pascal part), your data will be in .RC file like this
SaverSettingsDlg DIALOG 70, 130, 166, 75
STYLE WS_POPUP | WS_DLGFRAME | WS_SYSMENU
CAPTION "Settings for Boxes"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON "OK", 5, 115, 6, 46, 16
PUSHBUTTON "Cancel", 6, 115, 28, 46, 16
CTEXT "Box &Color:", 3, 2, 30, 39, 9
COMBOBOX 4, 4, 40, 104, 50, CBS_DROPDOWNLIST | CBS_HASSTRINGS
CTEXT "Box &Type:", 1, 4, 3, 36, 9
COMBOBOX 2, 5, 12, 103, 50, CBS_DROPDOWNLIST | CBS_HASSTRINGS
LTEXT "Boxes Screen Saver for Win32 Copyright (c) 1996 Jani
Järvinen.", 7, 4, 57, 103, 16,
WS_CHILD | WS_VISIBLE | WS_GROUP
END
are you really need this ? you save A LOT time using VCL, is the size really so critical ? what is the application is this ?
ASKER
No it's not important for me now to make so short program. I just asked to see how can I do that. Thank's
listenning
dont compile with packages(although first time deployment on some pcs may require some of the runtime libs to be deployed also),remove debugging info..
remove as many files from uses (ie if you only need one or two const from a unit use the consts in your program instead )
There is a program called Shrinker available. It compresses .EXE files and incorporates its expansion code into the file. It does a rather good job of compressing larger .EXE files.
http://www.aeronaut.com.au/hys_html/hys/Prod0153.htm