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
Solved

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

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

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 26

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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 2

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 2

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 2

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 2

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 2

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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

839 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