Examples Delphi

How do I make my exe size smaller ?
Remove the forms unit from the uses clause if you dont use anything from it.
This should make it much smaller.
******************************************************
Whilst it doesn't answer the question, one solution is an excellent product
like ASPack - written in Delphi!
http://www.entechtaiwan.com/aspack.htm
ASPack is used by Nevrona, Jordan Russell and ourselves to just name a few.
Well worth the registration of $25US IMHO - and worth checking out...
We normally reduce our exes to 30% to 40% of original size, plus it gives us
a bit of a deterrent against reverse-engineering.
A satisfied customer :-]
******************************************************
Glenn,
I've never used ASPack, but I have had great experience with Shrinker
from http://www.BlinkInc.com. I routinely get >60% compression, and
sometimes as high as 80%. I have one application that is only 71kb! It
contains a main form with numerous TEdits, a TRichEdit, a couple of
TTables, and all the code necessary for running in the system tray.
Bob M..
At 4/11/99 03:22 AM, Glenn Crouch wrote:
>Whilst it doesn't answer the question, one solution is an excellent product
>like ASPack - written in Delphi!
>
>http://www.entechtaiwan.com/aspack.htm
>
>ASPack is used by Nevrona, Jordan Russell and ourselves to just name a few.
>Well worth the registration of $25US IMHO - and worth checking out...
>
>We normally reduce our exes to 30% to 40% of original size, plus it gives
us
>a bit of a deterrent against reverse-engineering.
>
>A satisfied customer :-]
>
>Glenn Crouch, mailto:glenn@esbconsult.com.au ICQ: 36017076
>Manager Software Development, ESB Consultancy
>Home of ESBStats, ESBPDF and ESBCalc
>http://www.esbconsult.com.au
>(Team Nevrona, Addict Support, Delphi List Moderator)
>
******************************************************
Question:
Does anyone know how to make a simple form with a couple of visual
components and roughly 500 lines of source codes under 100kb ?

Answer:

You have two choices. First, if you are using D3, you can use the
packages technology, which is specifically designed to reduce EXE
size. See the help topic "About Packages" for details.

Second, you can build your application without using the VCL. You say
your application only has 500 lines of code, but this is flatly wrong:
if you use VCL components, your application has thousands or tens of
thousands of lines of code. There is a reason that programming in
Delphi is easy, and that reason is the lines of code inside the VCL
which you've used.

If having a smaller EXE is worth the considerable time, hassle, and
expense of programming directly to the Windows API, then feel free to
skip using the VCL and drop directly to the API.

Here's an example program which uses the API instead of the VCL. The
program shows how small the EXE can be with this approach (16K), and
also what a pain in the butt direct API programming is.

Program HelloWin;
{ Standard Windows API application written in Object Pascal.
}
Uses
Windows,
messages,
MMSystem;

Const
AppName : pChar = 'HelloWin';

Function WindowProc(Window:HWnd; AMessage, WParam,
LParam:LongInt):LongInt;
StdCall; Export;
{ The message handler for the new window
}
Var
h : hdc;
ps : tPaintStruct;
r : tRect;
Begin
Result := 0;
Case AMessage of
WM_Create:
Begin
PlaySound('C:\WINDOWS\MEDIA\Musica Windows Start.wav', 0,
Snd_FileName or Snd_Async);
Exit;
End;
WM_Paint:
Begin
h := BeginPaint(Window, Ps);
GetClientRect(Window, r);
DrawText(h, 'Hello Windows 95!', -1, r,
DT_SingleLine or DT_Center or DT_VCenter);
EndPaint(Window, ps);
Exit;
End;
WM_Destroy:
Begin
PostQuitMessage(0);
Exit;
End;
End;
Result := DefWindowProc(Window, AMessage, WParam, LParam);
End;
{ Register the window class
}
Function WinRegister:Boolean;
Var
WindowClass: TWndClass;
Begin
{WindowClass.cbSize := sizeof(WindowClass);}
WindowClass.Style := cs_HRedraw or cs_VRedraw;
WindowClass.lpfnWndProc := @WindowProc;
WindowClass.cbClsExtra := 0;
WindowClass.cbWndExtra := 0;
WindowClass.hInstance := HInstance;
WindowClass.hIcon := LoadIcon(0, idi_Application);
WindowClass.hCursor := LoadCursor(0, idc_Arrow);
WindowClass.hbrBackground := HBrush(GetStockObject(White_Brush));
WindowClass.lpszMenuName := NIL;
WindowClass.lpszClassName := AppName;
Result := RegisterClass(WindowClass)<>0;
End;

Function WinCreate:HWnd;
Var
HWindow:HWnd;
Begin
hWindow := CreateWindow(AppName,
'The Hello Program',
WS_OverlappedWindow,
CW_UseDefault,
CW_UseDefault,
CW_UseDefault,
CW_UseDefault,
0,
0,
HInstance,
NIL);
If hWindow<>0 then
Begin
ShowWindow(hWindow, CmdShow);
UpdateWindow(hWindow);
End;
Result := hWindow;
End;
{ Main: Set up window, then give it messages until done.
}
Var
AMessage: TMsg;
hWindow: HWnd;
Begin
If not WinRegister then
Begin
MessageBox(0, 'Register Failed', NIL, mb_Ok);
Exit;
End;
hWindow := WinCreate;
If hWindow=0 then
Begin
MessageBox(0, 'Register Failed', NIL, mb_Ok);
Exit;
End;
While GetMessage(AMessage, 0, 0, 0) do
Begin
TranslateMessage(AMessage);
DispatchMessage(AMessage);
End;
Halt(AMessage.WParam);
End.