Solved

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

Posted on 2014-07-31
10
978 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 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
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 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 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
 
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 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
 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

740 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