Page 1 of 1

Determining if processor/OS is 64bits

Posted: Thu Jan 15, 2009 9:04 pm
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,

Re: Determining if processor/OS is 64bits

Posted: Thu Jan 15, 2009 10:23 pm
by Antonio Linares
Luis,

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

Re: Determining if processor/OS is 64bits

Posted: Thu Jan 15, 2009 10:34 pm
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

Re: Determining if processor/OS is 64bits

Posted: Fri Jan 16, 2009 9:00 am
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"
 

Re: Determining if processor/OS is 64bits

Posted: Tue Jan 20, 2009 4:24 pm
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,