Determining if processor/OS is 64bits

Post Reply
User avatar
Luis Krause
Posts: 59
Joined: Tue Oct 11, 2005 1:39 am
Location: Vancouver, Canada

Determining if processor/OS is 64bits

Post by Luis Krause »

Hi all:

I'm wondering what's the best way to determine if the OS
running is 64bit or not. The need is basically to determine
if will install the 64 or 32 bit version of ADS 9x in our
installer.

I wonder if a simple GetEnv( "PROCESSOR_ARCHITECTURE" )
should be enough or is there a WinAPI call that's better
suited.

I know PROCESSOR_ARCHITECTURE returns x86 for 32 bit systems.
Since I don't have any 64bit system handy don't know if that
value is x64 or something else for 64bit systems.

Regards,
"May the Source be with GNU"
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Determining if processor/OS is 64bits

Post by Antonio Linares »

Luis,

This may help you: IsWow64Process()
http://msdn.microsoft.com/en-us/library ... S.85).aspx
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: Determining if processor/OS is 64bits

Post by Antonio Linares »

Luis,

Another way is to check the size of an integer, though this will just check the application itself, not the OS:

Code: Select all

#include "FiveWin.ch"

function Main()

  MsgInfo( SizeOfInt() == 8, "Am I 64 ?" )

return nil

#pragma BEGINDUMP

#include <hbapi.h>

HB_FUNC( SIZEOFINT )
{
   hb_retni( sizeof( int ) );
}

#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Determining if processor/OS is 64bits

Post by StefanHaupt »

Louis,

you can also check the environment variables PROCESSOR_ARCHITECTURE and PROCESSOR_IDENTIFIER to get those informations

Code: Select all

// OS 32bit shows x86, 64bit shows AMD64
lIsOs64 := (Upper (GetEnv("PROCESSOR_ARCHITECTURE")) = "AMD64" 

// 64 bit capeable processor shows EM64T
lIsCpu64 := Upper (GetEnv("PROCESSOR_IDENTIFIER")) = "EM64T"
 
kind regards
Stefan
User avatar
Luis Krause
Posts: 59
Joined: Tue Oct 11, 2005 1:39 am
Location: Vancouver, Canada

Re: Determining if processor/OS is 64bits

Post by Luis Krause »

Thanks for all the replies.
My first thought was PROCESSOR_ARCHITECTURE but I fear that only tells about the hardware, not the software.
I'll try the other approaches and see how they work and post my results later.

Regards,
"May the Source be with GNU"
Post Reply