Page 1 of 1
Forum

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!



Share:
Notifications
Clear all

[Solved] Lazarus - Windows - Detect 64bit Windows in a 32bit Application

1 Posts
1 Users
0 Reactions
3,796 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

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;    

   
ReplyQuote
Share: