Solved

Can my delphi XE app self-report if it was compiled 32 bit or 64 bit?

Posted on 2014-07-31
10
840 Views
Last Modified: 2014-08-01
I compile a math program for both 32-bit and 64-bit platforms. Both compile to BCD-Math.exe and when I copy them to my desktop I change the names to  Math-32.exe and Math-64.exe.  More often than not I have two or more instances of either or both executing. When executed both versions look identical and I invariably forget which open app is which. I could extract the file name and add it to the caption but was wondering if there is a way for an application to determine if it was compiled as a 32-bit or 64-bit app?
Its environment's tattle-tale so to speak.

(i.e. when launched, I'd add to the title bar to indicate "32-bit"  or  "64-bit"

Thanks
0
Comment
Question by:Ed-SSA
  • 5
  • 3
  • 2
10 Comments
 
LVL 25

Expert Comment

by:Sinisa Vuk
ID: 40233999
you can use compile directive:

sMyVersion: String;

{$IFDEF WIN32}
  sMyVersion := 'Win32';
{$ENDIF}
{$IFDEF WIN64}
  sMyVersion := 'Win64';
{$ENDIF}

...//use then sMyVersion to set label

Open in new window

0
 
LVL 25

Expert Comment

by:Sinisa Vuk
ID: 40234000
0
 
LVL 45

Accepted Solution

by:
aikimark earned 500 total points
ID: 40234017
You could have two global constants (same name) wrapped in a compiler directive that conditionally compiles one or the other, based on the WIN64 compiler conditional symbol.  When your application starts, you use that global constant to display your message.
0
 

Author Comment

by:Ed-SSA
ID: 40235102
Sinisa -  My OS Win 7 Pro is always "64-bit" whether I compile a 32-bit or 64-bit program.  I compile my program twice: one "Math.exe"  goes to  X\win32\Debug, a second compiles to  X\win32\Debug,  Then I copy both to my desktop changing the names to  Math-32.exe  and  Math-64.exe.  Once I open one by double clicking, there no indication in the program itself suggest it's the 32-bit or 64-bit version.  The code you provided correctly IDs windows as 64-bit no matter which Math-nn program is in execution.

What I'm trying to find is code that would say "I'm a 64-bit program"  or  "I'm a 32-bit program."

aikimark -  I was able to find that when I compile 32-bit programs, Delphi uses the DCC32 compiler and when I compile 64-bit programs, Delphi uses the DCC64 compiler but I could find any information on how to extract that info from a compiled program. Or am I missing something?

Thanks to both of you for trying.

- Ed
0
 
LVL 45

Expert Comment

by:aikimark
ID: 40235152
X\win32\Debug
both of your compiles are going to the same directory?  The second compile will overwrite the first compile
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 

Author Comment

by:Ed-SSA
ID: 40235223
aikimark -

I was able to figure it out:
{$IFDEF WIN64}
  compiledVer := '(64-bit)';
{$ELSE}
  compiledVer := '(32-bit)';
{$ENDIF}

Form1.Caption := 'BCDE Math    '+compiledVer;

Thanks so much !!
0
 

Author Closing Comment

by:Ed-SSA
ID: 40235227
(and thanks for making me work a little - I'd never done compiler directives before - seems like they may prove useful)
0
 

Author Comment

by:Ed-SSA
ID: 40235241
aikimark -
(oops)
 >> both of your compiles are going to the same directory?  The second compile will overwrite the first compile

No, it was a copy / paste and forgot to change 32 to 64. Given all the mistakes I make, this is likely the most common.

And thanks again for pointing me into unfamiliar but very useful territory.

- Ed
0
 
LVL 45

Expert Comment

by:aikimark
ID: 40235331
I was thinking constants (see example below), but both would work.
Const
{$IFDEF WIN64}
  compiledVer = '(64-bit)';
{$ELSE}
  compiledVer = '(32-bit)';
{$ENDIF}

Open in new window

0
 

Author Comment

by:Ed-SSA
ID: 40235345
Well now that you've shown me how, I'm thinking constants too !!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now