?
Solved

Formless application

Posted on 2000-03-04
18
Medium Priority
?
179 Views
Last Modified: 2010-04-04
Hi everybody!

I'm making a small application, which only copies a file from one to an other location. Is it possible to avoid the use of forms, because actually I don't need them. ( But i need some units to be included. )
I would be also happy of any suggestions on how to decrease the size of the application's EXE file ( of course if it is possible).

Thanx
0
Comment
Question by:xmary
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 3
  • +3
18 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 2583568
It's easy! This is all you need:


------ Project1.dpr -------

program Project1;

uses
  Windows,
  Unit1 in 'Unit1.pas';

begin
  if ParamCount >= 2 then
    CopyFile(PChar(ParamStr(1)), PChar(ParamStr(2)), false);
end.


------ Unit1.pas -------

unit Unit1;

interface

implementation

// put your function here

end.

--------------------------


You can easily add formless units using [File menu > New] and then select Unit.
0
 

Author Comment

by:xmary
ID: 2583922
Any suggestions about how to decrease the EXE file size?
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2583953
My example creates a 17 KB exe. You can't have it much smaller than that.
0
Independent Software Vendors: 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 1

Expert Comment

by:X_Kalibur
ID: 2584170
Epsylon,

Do you really even need "Unit 1"....

Cause when i write small formless apps, i code it straight into the main Project unit..

is there any advantage/disadvatage of dong it different ways?

-x
0
 

Author Comment

by:xmary
ID: 2584509
Hi Epsylon!

Could you please show me an example of such a code?

Thanx
0
 

Author Comment

by:xmary
ID: 2584526
To Epsylon:

Hi! I made a mistake on my last comment. Of course i did'n mean to show me an example of the code...it's on the top of the page. I meant if you have set up the compiler or linker to achieve such a small code.
0
 

Author Comment

by:xmary
ID: 2584537
To Epsylon:

I've written only the following code:

**Project1.dpr**

program Project1;

uses
  Dialogs;

begin
showmessage('hello');
end.

As you can see there isn't any form. But when i compiled it, the result was an 205kB executable...far away from 17 kB. Have I done something wrong? (I have Delphi 3)
0
 
LVL 3

Expert Comment

by:karouri
ID: 2584675
hmm
uses dialogs;
I suppose this will link in a lot of unnesessary code, only to use showmesssage.Am I right?
0
 
LVL 3

Expert Comment

by:Alisher_N
ID: 2584698
xmary!

go to File/New, choose 'Console application', exclude 'sysutils' from 'uses' if you don't need it.... you can't do it even smaller now
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2584735
X_Calibur:

>Do you really even need "Unit 1"....
No, I added it because xmary needed to


Alisher_N:

That's exactly the same as what I showed, so the size will be the same too...
include some (formless) units.


xmary:

I didn't setup anything in the linker or compiler. It's just a matter of what you 'use'. For example if you 'use' Dialogs, then the size increases and you can do very little about it except stipping the ShowMessage function from Dialogs.pas. And that's not easy. In this case you can better use Windows API functions like MessageBox. The API function MessageBox is defined in Windows.pas so put 'Windows' in the uses clause.


program Project1;

uses
  Windows;

begin
  MessageBox(0, 'Some text', 'My title', MB_OK);
end.
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2584736
Btw: this example creates a 16 KB exe....
0
 

Author Comment

by:xmary
ID: 2584910
To Epsylon:

Well, i thought i've done something wrong with the settings of the compiler, but if you say that the reason of the big filesize is the use of units, i think i can't do much. Above I made just an example of how little code is necessary to make a large file. (Actually I don't need to display that message.) In my application I have to use at least 3 units, so from what i understood, the executable will remain big.

Thanx anyway (if you wish, i can evaluate your answer)
0
 
LVL 13

Accepted Solution

by:
Epsylon earned 100 total points
ID: 2585167
Alright, thanks.
0
 
LVL 3

Expert Comment

by:darinw
ID: 2589593
This duplicate account has been suspended.

darinw
Customer Service
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2589711
Yes, and my points...?
0
 
LVL 3

Expert Comment

by:darinw
ID: 2589804
If this customer will not agree to abide by the Customer Agreement, then I will force the grade for you.

darinw
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 2625258
I guess you have to force it...
0
 
LVL 3

Expert Comment

by:darinw
ID: 2625374
Done.

darinw
Customer Service
0

Featured Post

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!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month15 days, 2 hours left to enroll

771 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