os-getenv("PROCESSOR_ARCHITECTURE") returns "x86" on 64bit machine

freak

Member
Running obsolete, ancient and unsupported Progress 9.1d 32bit on a 64bit machine.


On a 64bit machine at a command prompt I type "set" to see the system variables. It shows among other things...

Code:
PROCESSOR_ARCHITECTURE=AMD64

It's actually an Intel processor but at least it shows 64. But when I run a progress program on the same machine with the following code...

Code:
OS-GETENV("PROCESSOR_ARCHITECTURE")

...it responds "x86". That confuses me (and my program).

1. Does anyone know why it does this?

2. Is there a way to accurately find the bitness of the machine?
 

Cringer

ProgressTalk.com Moderator
Staff member
Aha! A simple work-around! message os-getenv("ProgramFiles(x86)") view-as alert-box. That environment variable is only set on 64bit machines. So it's ? if you're on a 32bit machine. Simples.
 

Osborne

Active Member
A couple more options, although not as nice and simple as the solution Cringer posted.

Option 1:
Code:
FUNCTION GetOSType RETURNS INTEGER ():
   DEFINE VARIABLE lpsysteminfo AS MEMPTR NO-UNDO.
   DEFINE VARIABLE procnum AS INTEGER NO-UNDO.
   DEFINE VARIABLE proctype AS CHARACTER NO-UNDO.

   SET-SIZE(lpsysteminfo) = 40.
   RUN GetNativeSystemInfo (INPUT-OUTPUT lpsysteminfo).

   ASSIGN ProcNum  = GET-SHORT(lpsysteminfo,1)
          ProcType = STRING(GET-LONG(lpsysteminfo,25)).
   IF ProcNum = 9 THEN
      IF ProcType = "8664" THEN
         RETURN 64.
   IF ProcNum = 0 THEN
      IF ProcType = "586" THEN
         RETURN 32.
   SET-SIZE(lpsysteminfo) = 0.
END FUNCTION.

PROCEDURE GetNativeSystemInfo EXTERNAL "kernel32.dll":
   DEFINE INPUT-OUTPUT PARAMETER lpSystemInfo AS MEMPTR.
END.

IF getOSType() = 64 THEN
   MESSAGE "System is 64-bit" VIEW-AS ALERT-BOX.
IF getOSType() = 32 THEN
   MESSAGE "System is 32-bit" VIEW-AS ALERT-BOX.

Option 2:
Code:
DEFINE VARIABLE cValue AS CHARACTER NO-UNDO.

LOAD "SYSTEM\CurrentControlSet\Control\Session Manager".
USE "SYSTEM\CurrentControlSet\Control\Session Manager".
GET-KEY-VALUE SECTION "Environment" KEY "PROCESSOR_ARCHITECTURE" VALUE cValue.
UNLOAD "SYSTEM\CurrentControlSet\Control\Session Manager".

IF cValue = "x86" THEN MESSAGE "This is a 32-bit edition" VIEW-AS ALERT-BOX.
ELSE MESSAGE "This is a 64-bit edition" VIEW-AS ALERT-BOX.
 

Osborne

Active Member
Regarding the question of why does OS-GETENV("PROCESSOR_ARCHITECTURE") gives "x86". I am not sure, but I think it is because the Progress version is 32-bit and "x86" is given when running a 32-bit application on a 64-bit OS.

To obtain the same value as you got when using the command prompt try this - not available on 32-bit so will return ?:
Code:
MESSAGE OS-GETENV("PROCESSOR_ARCHITEW6432") VIEW-AS ALERT-BOX INFORMATION.
 
Top