Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-07-31
10
Medium Priority
?
1,171 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
  • 5
  • 3
  • 2
10 Comments
 
LVL 28

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 28

Expert Comment

by:Sinisa Vuk
ID: 40234000
0
 
LVL 46

Accepted Solution

by:
aikimark earned 2000 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
Industry Leaders: 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

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…
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…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

824 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