Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!
Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.
Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!
[Solved] Lazarus - Windows - Detect 64bit Windows in a 32bit Application
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
September 13, 2018 12:50 AM
This is a small function to determine if your Windows is 64 bit, even if your application is 32 bit (add "windows" to your "uses" clause);
function t4a_Is64BitWindows: boolean;
{$IFDEF WIN32}
type
TIsWow64Process = function(Handle: Windows.THandle; var Res: Windows.BOOL): Windows.BOOL; stdcall;
var
IsWOW64: Windows.BOOL;
IsWOW64Process: TIsWow64Process;
{$ENDIF}
begin
{$IFDEF WIN32}
// Try to load required function from kernel32
IsWOW64Process := TIsWow64Process(Windows.GetProcAddress(Windows.GetModuleHandle('kernel32'), 'IsWow64Process'));
if Assigned(IsWOW64Process) then
begin
// Function exists
if not IsWOW64Process(Windows.GetCurrentProcess, IsWOW64) then
Result:=False
else
Result:=IsWOW64;
end
else
// Function not implemented: can't be running on Wow64
Result := False;
{$ELSE} //if were running 64bit code, OS must be 64bit :)
Result := True;
{$ENDIF}
end;