Link to home
Start Free TrialLog in
Avatar of mmilan
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
Avatar of inthe
inthe

hi,
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
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
Avatar of Alisher_N
Alisher_N

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mmilan

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(Width,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('MyDelphiScreenSaverClass','MySaver',
      ws_Child Or ws_Visible or ws_Disabled,0,0,
      Width,Height,ParentWindow,0,hInstance,nil)
  Else Begin
    Result := CreateWindow('MyDelphiScreenSaverClass','MySaver',
      ws_Visible or ws_Popup,0,0,Width,Height, 0,0,hInstance,nil);
    SetWindowPos(Result,hwnd_TopMost,0,0,0,0,swp_NoMove 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 ?
Avatar of mmilan

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