Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5929823
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:28:31+00:00 2026-05-22T14:28:31+00:00

I build four different types of applications with my framework: 1) Windows Services 2)

  • 0

I build four different “types” of applications with my framework:

1) Windows Services
2) Normal Applications
3) Service Applications (a normal application with the functionality of a Windows Service but with a local GUI console and an ability to auto-upgrade)
4) Remote GUI Consoles

Now I can detect, through code, if the application is a Windows Service. But currently to detect between the others I use DEFINES that need to be added to the project file. I would like find an alternate way that does not rely on DEFINES if possible. My initial thoughts are to use the Comments field of the project’s version info.

Any ideas?

Edit: I am after a general technique that works regardless of how I “type” my applications. At the moment I use DEFINES from the project configuration, which works, but makes the code slightly messier than using “if” code switches, and because it is stored in the .dproj file, can be hidden from view.

Solution: From David’s suggestion I initially used the conditional defines (and any other information such as whether the application was running as a Windows Service) to map all applications to one of the 4 application types, stored in a globally accessible object. Unless linking files that made no sense to include with a particular application type, I replaced almost all of my conditional compilation flags with code, which significantly improved the readability of the code. There are a few other “tweaks” I implemented, but that was the basic implementation.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:28:32+00:00Added an answer on May 22, 2026 at 2:28 pm

    Depending how you are using the Application global variable you can detect if you application is a Service, a VCL or a console App checking the type of this global variable. for consoles app you can use the System.IsConsole variable.

    function ApplicationIsService(Component:TComponent):Boolean;
    begin
       Result:=Component.ClassName='TServiceApplication';
    end;
    
    function ApplicationIsVcl(Component:TComponent):Boolean;
    begin
       Result:=Component.ClassName='TApplication';
    end;
    

    and you can use like this

    if ApplicationIsVcl(Application) then
    //do something
    else
    if ApplicationIsService(Application) then
    //do something else
    else
    if IsConsole then
    //do another thing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am building an inventory management application with four different user types: admin, employee,
I'm trying to build an authentication system in my application, but I'm having some
Preamble To build dynamic web-sites, we have to master at least four languages: HTML
I build VBA applications for both Word and Excel, is there any way to
Friday afternoon and all but hope that different timezones will help me with this...
I have an Apache Ant build file with a <javac> command that requires four
I have four small single-form utility applications that I have written in Delphi (Win32),
We have four public websites running on the same database with different schema(Oracle). All
I have a PHP application that is written with Zend Framework. It uses Phing
I have build a simple dedicated browser (like Prism) which I use for different

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.