Solved

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

Posted on 2014-07-31
10
1,054 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 Covney
[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
  • 5
  • 3
  • 2
10 Comments
 
LVL 27

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 27

Expert Comment

by:Sinisa Vuk
ID: 40234000
0
 
LVL 46

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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 3

Author Comment

by:Ed Covney
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 46

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
 
LVL 3

Author Comment

by:Ed Covney
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
 
LVL 3

Author Closing Comment

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

Author Comment

by:Ed Covney
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 46

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
 
LVL 3

Author Comment

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

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month9 days, 8 hours left to enroll

623 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