Solved

delete properties and methods...?

Posted on 2002-06-24
11
236 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
ID: 7106366
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
ID: 7106369
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
ID: 7106409
sorry i meant Bevel not frames...

Sorry about my English
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:robert_marquardt
ID: 7106499
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 34

Expert Comment

by:Slick812
ID: 7106523
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
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 7106609
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
ID: 7106620
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
ID: 7109503
Where can I find UPX ? is it freeware ?

Regards
Adeng
0
 
LVL 34

Expert Comment

by:Slick812
ID: 7111596
here is one page addy for UPX a FREE .exe packer

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

Expert Comment

by:Gwena
ID: 7111921
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
ID: 7287460
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
find a node in VST 2 78
Delphi 2 77
PHP preg_replace code convert to Delphi 14 80
Firemonkey allowing RTL on android 6 56
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

756 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