Salesforce

How to programmatically determine bitness in an ABL session running on Windows?

« Go Back

Information

 
TitleHow to programmatically determine bitness in an ABL session running on Windows?
URL Name000054631
Article Number000181643
EnvironmentProduct: OpenEdge
Version: 11.3, 11.4, 11.5, 11.6, 11.7
OS: All Supported Platforms
Question/Problem Description
How to detect 32-bit or 64-bit OpenEdge versions in ABL code running on Windows?
ABL code to display whether a 32-bit or a 64-bit OpenEdge client is running on Windows.
ABL code for Windows to determine if the running client is a 32-bit or 64-bit process.
How to programmatically determine bitness in ABL?
How can I tell if my code is running on a 32 or 64 bit Progress executable?
How to tell whether ABL code is running in a 32-bit or 64-bit OpenEdge client process?
How to report whether a 32-bit or 64-bit AVM is running?
How can I tell if my code is running on a 32 or 64 bit Progress executable?
How to tell whether ABL code is running in a 32-bit or 64-bit OpenEdge client process?
How to report whether a 32-bit or 64-bit AVM is running?
How to detect the architecture of a Progress client running on Windows?
Steps to Reproduce
Clarifying Information
It may be necessary to determine if ABL code is running in a 32-bit or a 64-bit Windows process because:
  • Pointer sizes differ on the 32-bit and 64-bit platforms. When passing pointer parameters to external DLLs, the correct type (LONG or INT64) must be chosen to accommodate the full size of the pointer.
  • Many Windows DLLs are built for only 32-bit platforms, or only 64-bit platforms. It may be necessary to specify the a different DLL to call depending on the platform
  • System files and registry keys used with 32-bit processes on 64-bit Windows are stored in a "SysWOW64" folder or registry hive rather than a "System" or "System32" folder or registry hive. In many cases the Windows OS chooses the correct location transparently, but the application code may make explicit references to directory paths or registry keys.
Error Message
Defect Number
Enhancement Number
Cause
Resolution
Progress introduced a 64-bit Windows product in OpenEdge 10.2A. This was a Server-only product that included a 64-bit character (TTY) client. A 32-bit GUI client was also included; this was intended for running GUI Administration tools such as the Data Dictionary only.

Progress introduced a full 64-bit Windows GUI client in OpenEdge 11.3. The PROCESS-ARCHITECTURE function was also introduced in OE 11.3; this function returns an integer value "32" or "64" depending on whether the code is running in a 32-bit or 64-bit version of OpenEdge.

The following ABL code uses the PROCESS-ARCHITECTURE, PROVERSION, and WINDOW-SYSTEM preprocessor variables to compile the correct code for the OpenEdge version and platform on which the code is being compiled. The code will correctly detect:
  • 32-bit or 64-bit versions of OpenEdge in release 11.3 and later
  • OpenEdge releases which only have 32-bit Windows clients (10.1C and earlier for character clients, 11.2 and earlier for GUI clients)
  • OpenEdge releases in which a 32-bit or a 64-bit client may be running, but it is impossible to determine which because the PROCESS-ARCHITECTURE function is not available (10.2A through 11.2 character clients). In this case the code defaults to the 32-bit assumption and notifies the user
As an example of the type of information that might be set conditionally based on a 32-bit or 64-bit process, this code defines the following preprocessor variables:
  • POINTERTYPE ("LONG" for 32-bit processes or "INT64" for 64-bit processes)
  • POINTERSIZE (4 for 32-bit processes or 8 for 64-bit processes)
While Windows system directory and registry hive locations are not relevant to UNIX systems, pointer size remains an issue. This example is restricted to Windows clients for simplicity, but it can be modified to account for the versions in which 64-bit character clients became available on various UNIX platforms. The check for WINDOW-SYSTEM would not be needed for UNIX because only character (TTY) clients are available on those platforms. See the References to Other Documentation below for the versions in which 64-bit clients are available on various Unix platforms.
 
/* WindowsGeneral_3264.i */

&IF PROVERSION <= '8' &THEN  /* OE 10+ */

    &IF PROVERSION >= '11.3' &THEN   /* PROCESS-ARCHITECTURE function is available */
    
        &IF PROCESS-ARCHITECTURE = 32 &THEN /* 32-bit pointers */
            &GLOBAL-DEFINE POINTERTYPE 'LONG'
            &GLOBAL-DEFINE POINTERBYTES 4
            MESSAGE '11.3+ 32-bit' VIEW-AS ALERT-BOX.
        &ELSEIF PROCESS-ARCHITECTURE = 64 &THEN /* 64-bit pointers */
            &GLOBAL-DEFINE POINTERTYPE 'INT64'
            &GLOBAL-DEFINE POINTERBYTES 8
            MESSAGE '11.3+ 64-bit' VIEW-AS ALERT-BOX.
        &ENDIF  /* PROCESS-ARCHITECTURE */
        
    &ELSE   /* Can't check architecture pre-11.3 so default to 32-bit */
        &GLOBAL-DEFINE POINTERTYPE 'LONG'
        &GLOBAL-DEFINE POINTERBYTES 4
        MESSAGE 'pre-11.3 -- defaulting to 32-bit' VIEW-AS ALERT-BOX.

        /* TTY 10.2A - 11.2 client might be 64-bit, so alert user if not in batch mode.
            Batch mode clients cannot respond to alert, but messages will appear in
            standard output to aid in debugging if code is run on wrong platform. */
        &IF PROVERSION >= '10.2A' &THEN
        
            &IF "{&WINDOW-SYSTEM}" = "TTY" &THEN
                MESSAGE
                    'WARNING: Defaulting to 32-bit printer enumeration' SKIP
                    'This procedure will not operate correctly in an OpenEdge'
                    PROVERSION '64-bit client' SKIP 'Proceed?'
                    VIEW-AS ALERT-BOX WARNING BUTTONS YES-NO UPDATE lProceed AS LOGICAL.
                IF NOT lProceed THEN QUIT.
                MESSAGE 'Proceeding...' VIEW-AS ALERT-BOX.
            &ENDIF  /* WINDOW-SYSTEM */
            
        &ENDIF  /* PROVERSION > 10.2A */
        
    &ENDIF  /* PROVERSION > 11.3 */
    
&ELSE   /* pre-OE10 always 32-bit on Windows */
    MESSAGE 'pre-OE10 -- defaulting to 32-bit' VIEW-AS ALERT-BOX.
    &GLOBAL-DEFINE POINTERTYPE 'LONG'
    &GLOBAL-DEFINE POINTERBYTES 4
&ENDIF  /* PROVERSION < 8 */

Note: This function has a corresponding preprocessor. {&PROCESS-ARCHITECTURE} expands to either "32" or "64".
 
Workaround
Notes
Keyword Phrase
Last Modified Date11/20/2020 7:06 AM

Powered by