Solved

delete properties and methods...?

Posted on 2002-06-24
11
224 Views
Last Modified: 2010-04-04
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
0
Comment
Question by:ebi1
  • 4
  • 2
  • 2
  • +2
11 Comments
 

Author Comment

by:ebi1
Comment Utility
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
 

Author Comment

by:ebi1
Comment Utility
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
 

Author Comment

by:ebi1
Comment Utility
sorry i meant Bevel not frames...

Sorry about my English
0
 
LVL 11

Expert Comment

by:robert_marquardt
Comment Utility
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
 
LVL 33

Expert Comment

by:Slick812
Comment Utility
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 11

Expert Comment

by:robert_marquardt
Comment Utility
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
 
LVL 5

Accepted Solution

by:
Gwena earned 200 total points
Comment Utility
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
 
LVL 1

Expert Comment

by:adeng
Comment Utility
Where can I find UPX ? is it freeware ?

Regards
Adeng
0
 
LVL 33

Expert Comment

by:Slick812
Comment Utility
here is one page addy for UPX a FREE .exe packer

http://upx.sourceforge.net/
0
 
LVL 5

Expert Comment

by:Gwena
Comment Utility
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
 

Author Comment

by:ebi1
Comment Utility
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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now