Salesforce

How to determine the bitness of Windows?

« Go Back

Information

 
TitleHow to determine the bitness of Windows?
URL Namehow-to-determine-the-bitness-of-windows
Article Number000125026
EnvironmentProduct: OpenEdge
Version: All Supported Versions
OS: Windows
Question/Problem Description

Below are two different code samples for determining the bitness of the Windows installation that OpenEdge is running in.
 
Steps to Reproduce
Clarifying Information
Error Message
Defect Number
Enhancement Number
Cause
Resolution

In OpenEdge 11.0 and later versions .NET Framework 4.0 is used.  This version of the .NET Framework introduced the System.Environment.is64BitOperatingSystem property that can be easily checked at runtime to determine if the currently running Windows OS is 32 or 64 bit.
USING System.Environment.*.

MESSAGE System.Environment:is64BitOperatingSystem VIEW-AS ALERT-BOX.
Prior to .NET 4.0 this task was a bit more convoluted.  Below is sample code which extrapolates this information from multiple sources.
DEFINE VARIABLE iProcess      AS INTEGER     NO-UNDO.
DEFINE VARIABLE iWow64Process AS INTEGER     NO-UNDO.
DEFINE VARIABLE iResultValue  AS INTEGER     NO-UNDO.
DEFINE VARIABLE iOEBitness    AS INTEGER     NO-UNDO.

RUN GetCurrentProcess( OUTPUT iProcess ).
RUN IsWow64Process( INPUT iProcess, 
                    INPUT-OUTPUT iWow64Process, 
                    OUTPUT iResultValue ).
RUN getOEBitness ( OUTPUT iOEBitness ).

/* iWow64Process = 0 if both Windows and OpenEdge are 64-bit, 
   or if both are 32-bit. */
IF iWow64Process GT 0 AND 
   iOEBitness    EQ 32 THEN
    MESSAGE "32-bit OpenEdge running on 64-bit Windows" 
        VIEW-AS ALERT-BOX.
IF iWow64Process EQ 0 AND
   iOEBitness    EQ 32 THEN
    MESSAGE "32-bit OpenEdge running on 32-bit Windows"
        VIEW-AS ALERT-BOX INFO BUTTONS OK.
IF iWow64Process EQ 0 AND 
   iOeBitness    EQ 64 THEN
    MESSAGE "64-bit OpenEdge running on 64-bit Windows"
        VIEW-AS ALERT-BOX INFO BUTTONS OK.

PROCEDURE GetCurrentProcess EXTERNAL "kernel32.dll":
   DEFINE RETURN PARAMETER iProcess AS LONG.
END.

PROCEDURE IsWow64Process EXTERNAL "kernel32.dll":
   DEFINE INPUT        PARAMETER iProcess      AS LONG.
   DEFINE INPUT-OUTPUT PARAMETER iWow64Process AS HANDLE TO LONG.
   DEFINE RETURN       PARAMETER iResultValue  AS LONG.
END.

PROCEDURE getOEBitness:
    DEFINE OUTPUT PARAMETER piBitness AS INTEGER     NO-UNDO.

    &IF PROVERSION GT '11.3' &THEN   /* PROCESS-ARCHITECTURE function is available */
        piBitness = PROCESS-ARCHITECTURE.
    &ELSE   /* Can't check architecture pre-11.3 so default to 32-bit */
        piBitness = 32.
    &ENDIF
END PROCEDURE.
For more details on determining the bitness of the OpenEdge process see (How to programmatically determine bitness in an ABL session running on Windows?).
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 7:06 AM

Powered by