FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Determining if processor/OS is 64bits
Posts: 59
Joined: Tue Oct 11, 2005 01:39 AM
Determining if processor/OS is 64bits
Posted: Thu Jan 15, 2009 09:04 PM

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"
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Determining if processor/OS is 64bits
Posted: Thu Jan 15, 2009 10:23 PM

Luis,

This may help you: IsWow64Process()

http://msdn.microsoft.com/en-us/library/ms684139(VS.85).aspx

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Determining if processor/OS is 64bits
Posted: Thu Jan 15, 2009 10:34 PM
Luis,

Another way is to check the size of an integer, though this will just check the application itself, not the OS:
#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
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Determining if processor/OS is 64bits
Posted: Fri Jan 16, 2009 09:00 AM
Louis,

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

// 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
Posts: 59
Joined: Tue Oct 11, 2005 01:39 AM
Re: Determining if processor/OS is 64bits
Posted: Tue Jan 20, 2009 04:24 PM

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"

Continue the discussion