Link to home
Start Free TrialLog in
Avatar of Sam80
Sam80

asked on

How to program a small delphi application?

Hi all,
  I found that the application compiled from delphi is so big ! Even I havent add any thing to the form , the app after complied is also 300K above , in fact ,some times I neednt use GUI to do my job ,how can I remove the form and just compile the part that has the function I want ?

Regards,
Sam
Avatar of mokule
mokule
Flag of Poland image

You can create Console Application
Avatar of shaneholmes
shaneholmes

NO GUI Delphi applications - Page 1/2
Creating a console mode application with Delphi; a text-mode program that runs without a graphical interface. Even more: see how to capture the output of a console application in a GUI Delphi program.

http://delphi.about.com/library/weekly/aa091101a.htm

NO GUI Delphi applications - Page 2/2
Creating a console mode application with Delphi; a text-mode program that runs without a graphical interface. Even more: see how to capture the output of a console application in a GUI Delphi program.

http://delphi.about.com/library/weekly/aa091101b.htm

Shane
Or you could try using ASPack on your Executables to shrink them - thats what i use.

www.aspack.com


Shane
Here is another good simple article on Consoles Applications in Delphi!

Console applications in Delphi
http://www.geocities.com/SiliconValley/Lakes/1636/con_apps.htm

How to determine the output of a console application
http://delphi.about.com/cs/adptips2003/a/bltip0803_5.htm

Shane





   If you want console application here is what you have to do ...

   1) Project / View Source to open the DPR file
   2) in Uses clause remove Form unit
   3) on the second line after project clause put {$APPTYPE CONSOLE}
   4) remove Unit1 from the project ...
Or just by clicking

File / New / Other /Console Application
If you want that your exe file will small, do everything with WinAPI.
Other way is to compress with any utilitties.
UPX Graphical
AsPack(www.aspack.com)
PeCompact(www.collakesoftware.com) and others.
Hi,

if you don't want a console application, in the dpr remove the Forms from the uses clause, {$R *.res}, Application ...

here's an example:

program Project1;

function Sum(a, b : integer): integer;
begin
  Result := a+b;
end;

var
  mySum : integer;
begin
  mySum := Sum(1, 3);
end.

Bogdan
Avatar of Sam80

ASKER

I did followed what you say, but what about the DOS window? how Can I hide it ? I use console application .

Sam
If you have gone the Console Application route, just

comment out {$APPTYPE CONSOLE}


Shane
// {$APPTYPE CONSOLE}

Shane
yes, remove {$APPTYPE CONSOLE}

Bogdan
Avatar of Sam80

ASKER

In console application , I want to hold my application for several minutes, not terminated as it run to the last code. how to do it ??

Sam
program Project1;

{$APPTYPE CONSOLE}

uses
  Windows, SysUtils;

{$R *.RES}

begin
  WriteLn('Hello World!');

  // your code here ... Do what ever you want

  // some delay
  Sleep(1000);

  WriteLn('Finishing...');
  Halt(0);
end.
Three things -

1. Debug (project..Options..Compiler tab, Linker tab) will bloat your programs, sometimes up to 8 times their normal size. Removal of the Debugging options and Include TD32  debug info will shrink the programs footprint (but will no longer be able to debug).  In addition delete the debug lines from the top of the source ({INCLUDE DEBUG} etc).

2. an excellent article sequence on creating small Delphi programs is available here .

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

3. Use diskIO once and keep inline - such as using inifiles to load at creation internal data then use saved retrieved values rather than getting them again... and again... and again...
Avatar of Sam80

ASKER

Initially , I want to create a little chat program, but it seems different between console application and the normal application, I cannot write the codes in the socket  event, like the onReceive and onaccept events.

Sam
ASKER CERTIFIED SOLUTION
Avatar of Member_2_248744
Member_2_248744
Flag of United States of America image

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