Ed Covney
asked on
Can my delphi XE app self-report if it was compiled 32 bit or 64 bit?
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
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
X\win32\Debugboth of your compiles are going to the same directory? The second compile will overwrite the first compile
ASKER
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 !!
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 !!
ASKER
(and thanks for making me work a little - I'd never done compiler directives before - seems like they may prove useful)
ASKER
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
(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
I was thinking constants (see example below), but both would work.
Const
{$IFDEF WIN64}
compiledVer = '(64-bit)';
{$ELSE}
compiledVer = '(32-bit)';
{$ENDIF}
ASKER
Well now that you've shown me how, I'm thinking constants too !!
Open in new window