Solved

{$APPTYPE CONSOLE} ?

Posted on 2003-11-01
3
841 Views
Last Modified: 2008-02-01
What is {$APPTYPE CONSOLE}, and how do you make a program that just executes in a dos window if you do not want to use forms in your project?
0
Comment
Question by:herd_bone
[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
3 Comments
 
LVL 2

Accepted Solution

by:
DeNavigator earned 65 total points
ID: 9662394
You just said it yourself! :)
To make a Console application:
Choose New -> Other -> Console Application
in your Delphi IDE.
{$APPTYPE CONSOLE} is a compiler directive, which tells the compiler what kind of program to generated.
0
 

Author Comment

by:herd_bone
ID: 9662400
thanks main!
0
 
LVL 5

Expert Comment

by:DeerBear
ID: 9662492
Hi,

{$APPTYPE CONSOLE} tells the Delphi compiler that you're doing a
console app, without forms, executing in a DOS window.

When you're using this kind of app, the compiler AllocateConsole for you.
You can then DeallocateConsole and AllocateConsole if you want a better
configuration or a personalized one.

You create a new console application through the File|New... dialog,
choosing "console application".

The big advantage of console apps is that you can still use Delphi
non visual components and datamodules.

See this:

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils;

begin
  { Insert code here }
end.

Now, imagine we created a datamodule called TMyDataModule in
unit "uMyDataModule".

You can modify the former in:

program Project2;

{$APPTYPE CONSOLE}

uses
  SysUtils, uMyDataModule;

begin
  { Insert code here }
  with TMyDataModule.Create( nil ) do
  begin
    // Method calls here
    Free;
  end;
end.

To gather parameters you can use ParamStr as you
would do with plain Windows applications.

ParamStr directly descends from the corresponding
Turbo Pascal instruction.

Special considerations should be done in several areas:

1) I/O handlers: it's my opinion that standard handlers should
never be overdriven to new sources. If you want to have other
kinds of I/O devices you should use parameters or redirection at the
command prompt level or through CreateProcess API.

2) You won't be able to use visual controls( of course ) for the lack of
forms, but you'll be able to use the Windows APIs.

3) To make a TP-Like program you'll need a WinCrt clone.
There're a number out there, I'd suggest either the Ben Ziegler one or a
free one whose name I don't recall right now.

4) Remember that at the end of the game a console app is simply a
special type of Windows app, thus you'll lose things like Port and Mem
with their extended versions( PortW,PortL, etc ).

HTH,

Andrew
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show Listview image from database (String field) 5 150
Delphi: Connect to running MS Outlook 4 165
TEMBEDDEDWB how can i change its user agent ? 8 84
IP without any Dots 1 59
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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

726 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