Short answer: Use the GetSystemInfo
function of the Windows API to find out if the system is 32-bit or 64-bit.
Example code:
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils, Windows;
var
si: TSystemInfo;
const
PROCESSOR_ARCHITECTURE_AMD64 = 9;
PROCESSOR_ARCHITECTURE_IA64 = 6;
PROCESSOR_ARCHITECTURE_INTEL = 0;
PROCESSOR_ARCHITECTURE_UNKNOWN = $FFFF;
begin
GetSystemInfo(si);
case si.wProcessorArchitecture of
PROCESSOR_ARCHITECTURE_AMD64: Writeln('AMD64');
PROCESSOR_ARCHITECTURE_IA64: Writeln('IA64');
PROCESSOR_ARCHITECTURE_INTEL: Writeln('Intel');
PROCESSOR_ARCHITECTURE_UNKNOWN: Writeln('Unknown');
end;
Readln;
end.
The two most common outputs are 'Intel' (32-bit x86) and 'AMD64' (64-bit x64). In fact, you can more or less trust that you will get one of those.
Now, in reality, I believe that the above program will always return 'Intel' (32-bit x86) because all Delphi applications are 32-bit, and so they are emulated under a 64-bit Windows (using WOW64) -- there is no 64-bit release of the Delphi compiler and IDE.
So to obtain the true architecture of the system, regardless of emulation, you have to use the GetNativeSystemInfo
function. There is no wrapper for this function, so you have to import it yourself from kernel32.dll.
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils, Windows;
var
si: TSystemInfo;
const
PROCESSOR_ARCHITECTURE_AMD64 = 9;
PROCESSOR_ARCHITECTURE_IA64 = 6;
PROCESSOR_ARCHITECTURE_INTEL = 0;
PROCESSOR_ARCHITECTURE_UNKNOWN = $FFFF;
procedure GetNativeSystemInfo(var lpSystemInfo: TSystemInfo); stdcall; external kernel32 name 'GetNativeSystemInfo';
begin
GetNativeSystemInfo(si);
case si.wProcessorArchitecture of
PROCESSOR_ARCHITECTURE_AMD64: Writeln('AMD64');
PROCESSOR_ARCHITECTURE_IA64: Writeln('IA64');
PROCESSOR_ARCHITECTURE_INTEL: Writeln('Intel');
PROCESSOR_ARCHITECTURE_UNKNOWN: Writeln('Unknown');
end;
Readln;
end.