Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: RAD 2010 detecting is computer is 32 or 64 bit


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 5 - Last Post: Nov 15, 2016 10:21 AM Last Post By: Remy Lebeau (Te...
Alan Jordan

Posts: 228
Registered: 3/2/01
RAD 2010 detecting is computer is 32 or 64 bit  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2016 8:02 AM
Are there any methods in Delphi to detect 32 or 64 bit operating system?
Andrew Law

Posts: 74
Registered: 11/6/02
Re: RAD 2010 detecting is computer is 32 or 64 bit  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2016 10:06 AM   in response to: Alan Jordan in response to: Alan Jordan
Alan Jordan wrote:
Are there any methods in Delphi to detect 32 or 64 bit operating system?

I believe this is already answered on StackOverflow:

http://stackoverflow.com/questions/8144599/getting-the-windows-version
Alan Jordan

Posts: 228
Registered: 3/2/01
Re: RAD 2010 detecting is computer is 32 or 64 bit  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2016 10:10 AM   in response to: Alan Jordan in response to: Alan Jordan
Thanks
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: RAD 2010 detecting is computer is 32 or 64 bit  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Sep 12, 2016 2:32 PM   in response to: Alan Jordan in response to: Alan Jordan
Alan wrote:

Are there any methods in Delphi to detect 32 or 64 bit
operating system?

The Win32 API GetNativeSystemInfo() function, which is wrapped by the SysUtils.TOSVersion
class.

--
Remy Lebeau (TeamB)
ibrahim pazinger

Posts: 1
Registered: 4/27/08
Re: RAD 2010 detecting is computer is 32 or 64 bit  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 14, 2016 10:02 PM   in response to: Alan Jordan in response to: Alan Jordan
Are there any methods in Delphi to detect 32 or 64 bit operating system?
Yes ther are simple way, the following code will help you, i use it my self and it works just fine!

1st add the units :
uses Windows, Sysutils, stdCtrls;

to the uses cluster, then add the following function which will returns true if you are running 64 bit OS;

function IsWin64: Boolean;
var
IsWow64Process : function(hProcess : THandle; var Wow64Process : BOOL): BOOL; stdcall;
Wow64Process : BOOL;
begin
Result := False;
IsWow64Process := GetProcAddress(GetModuleHandle(Kernel32), 'IsWow64Process');
if Assigned(IsWow64Process) then begin
if IsWow64Process(GetCurrentProcess, Wow64Process) then begin
Result := Wow64Process;
end;
end;
end;

Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: RAD 2010 detecting is computer is 32 or 64 bit  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Nov 15, 2016 10:21 AM   in response to: ibrahim pazinger in response to: ibrahim pazinger
ibrahim wrote:

Yes ther are simple way, the following code will help you, i use
it my self and it works just fine!

That code tests whether the calling process is running inside the WOW64 emulator
or not (ie, whether the calling process is a 32bit app running on a 64bit
system). It does not account for a 64bit process running on a 64bit system.
At the very least, add an IFDEF for that:

function IsWin64: Boolean;
{$IFNDEF WIN64}
var
  IsWow64Process : function(hProcess : THandle; var Wow64Process : BOOL): 
BOOL; stdcall;
  Wow64Process : BOOL;
{$ENDIF}
begin
  {$IFDEF WIN64}
  Result := True;
  {$ELSE}
  Result := False;
  IsWow64Process := GetProcAddress(GetModuleHandle(Kernel32), 'IsWow64Process');
  if Assigned(IsWow64Process) then begin
    if IsWow64Process(GetCurrentProcess, Wow64Process) then begin
      Result := Wow64Process;
    end;
  end;
  {$ENDIF}
end;


Another way to check whether the OS is 32bit or 64bit is to just ask the
OS directly, eg:

function IsWin64: Boolean;
var
  GetNativeSystemInfo: procedure(var lpSystemInformation: TSystemInfo); stdcall;
  SysInfo: TSystemInfo;
begin
  GetNativeSystemInfo := GetProcAddress(GetModuleHandle(Kernel32), 'GetNativeSystemInfo');
  if Assigned(GetNativeSystemInfo) then
    GetNativeSystemInfo(SysInfo)
  else
    GetSystemInfo(SysInfo);
  Result := (SysInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_AMD64) 
or
              (SysInfo.wProcessorArchitecture = PROCESSOR_ARCHITECTURE_IA64);
end;


--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02