delete properties and methods...?

Hi all,

I'm using Delphi2 for something i want to be as SMALL as possible.

I'm using Delphi only as a hobby, so i'm not a pro...

I know almost nothing about OO.

Since i want my program to be VERY small, is it possible to delete properties and/or methods i don't use, and by doing so reducing the EXE size ?
Example :
I don't use the cursor and PopupMenu (and others) properties and everything related to them.
and from the "Dialogs" unit i ONLY use MessageBox (and of course i'm not talking only about the "Dialogs" unit)
So... can i delete what i DON'T need?

If it can be done please give me a GOOD example.

ThanX
ebi1Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
GwenaConnect With a Mentor Commented:
Hi :-)



  If you want small exe size above all then you need to use the Key Objects Library ..  http://bonanzas.rinet.ru/

If you use KOL and also use the substitute system.dcu then you can get a delphi app down quite a bit less than 20kb.

If you then UPX with the highest compression level
UPX --best MyProgram.exe then you can get below 15kb easily

There are a few other tricks to squeeze even more out but once you are under 20kb then what does it really matter... that's like only a few seconds to download even on a 56k modem :-)

To get an exe below 10kb you can use the free BCX (basic to C convertor)  this uses the great freeware lcc C compiler.  If you upx the BCX exe files you can get under 5kb for a useful gui utility program... and that is pretty small.

To get below 3kb for a useful exe then you need to go to Win32 Assembly language... there is a nice free RAD development kit that uses the free nasm compiler to make windows gui programs.. http://www.visual-assembler.pt.vu/

And believe it or not you can even find ways to make the <3kb asm windows apps smaller!  and you can find plenty of space inside them to stuff data... it's amazing :-)


The reason a gui windows program can be so small is because you are calling code from windows dll's to do all the hard work... if you develop a taste for tiny apps then I suggest you try to learn all you can about the windows API... once you understand the API you can easily make small programs. Most of the code to make nice windows apps is just waiting inside the windows dll's for you to call.


to summarize...
The 4 ways that I use to make small exe files.
These are figures for a small util app like a
file patcher or file editor..etc

-Delphi 2 and then upx  ---> about 110kb
-Delphi and KOL library w/system dcu ---> about 20kb
-BCX and lcc ---> about 10kb
-C program using API ---> about 6kb
-Win32 asm ---> about 3kb

0
 
ebi1Author Commented:
BTW : I use "Resource Hacker" and UPX (level 9) to reduce my EXE.

I have a Gouge, RxLib Animated GIF (24k), a few labels and a button.

Acording to what someone once told me - I use Frames instead of Panels to avoid the use of Handle (memory/size).

After all that i can't get my EXE file lower then 145k.

Please help.
ThanX
0
 
ebi1Author Commented:
BTW : I use "Resource Hacker" and UPX (level 9) to reduce my EXE.

I have a Gouge, RxLib Animated GIF (24k), a few labels and a button.

Acording to what someone once told me - I use Frames instead of Panels to avoid the use of Handle (memory/size).

After all that i can't get my EXE file lower then 145k.

Please help.
ThanX
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ebi1Author Commented:
sorry i meant Bevel not frames...

Sorry about my English
0
 
robert_marquardtCommented:
The best way is to completely drop the use of the VCL. There are free replacements out there which allow to drop EXE size considerably. Have a look at Torry's Pages and Delphi Super Page.
0
 
Slick812Commented:
I often comment out things in my uses clause to see if they are needed

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, {Dialogs,} Buttons, StdCtrls;

if it will compile with the unit commented out then I delete it because it is no longer nessary. If you really want to get the smallest file size then you will need to do API without the Forms unit, but that takes time to learn, you can look at my web site to see if you want to try and do that

http://www.angelfire.com/hi5/delphizeus/

if you use the Forms unit, even with Delphi2 and the UPX you can't get much below 150 Kb. With API many programs are below 100 Kb and then below 50 KB with UPX.
0
 
robert_marquardtCommented:
Keep in mind that EXE size does not mean much to Windows. The memory footprint is quite another question.
EXEs are only loaded partly into memory. Using Quick Report for example easily makes 1.5 MB EXEs. Most of the code is not permanently loaded.
0
 
adengCommented:
Where can I find UPX ? is it freeware ?

Regards
Adeng
0
 
Slick812Commented:
here is one page addy for UPX a FREE .exe packer

http://upx.sourceforge.net/
0
 
GwenaCommented:
UPX is great for single instance executables..

But remember that if your exe will have many instances running at the same time that each will occupy memory if it is compressed...when an exe is uncompressed all the instances will use the same original image in ram.

just something to keep in mind :-)
0
 
ebi1Author Commented:
Hey there,

Sorry about the delay guys, I totaly forgot about this question...

Nobody actualy answered my question but I never knew about the KOL so for me it's a BIG thing...

Thank you Gwena, helpful as always...   :)

Slick - you will also get some points because i learned many good things from your site.
Thank you
0
All Courses

From novice to tech pro — start learning today.