Skip to main content

Chris,

I testet both methods on 2 PC's with W7prof. 32bit-version. pp was <> null and OS64Path <> space

Chris,

I testet both methods on 2 PC's with W7prof. 32bit-version. pp was <> null and OS64Path <> space

Here is a revision as I noticed that the IsWow64 function call is in later 32-bit versions of Windows so you must actually call the function if it exists.
Note that this will only work from a 32-bit compiled program as actual 64-bit programs do not run under Wow64.

The environment variable method works for me.
Can you please tell me what exactly is returned for the OS64Path variable under 32-bit Windows?

 

      $set case                                                       
       id division.                                                   
       program-id.  testwin64.                                        
       special-names.                                                 
          call-convention 66 is winapi.                               
       working-storage section.                                       
       01 pp           procedure-pointer.                             
       01 procid       pic x(4)  comp-5 value 0.                      
       01 wowprocess   pic x(4)  comp-5 value 0.                      
       01 wsbool       pic x(4)  comp-5 value 0.                      
       01 OS64Path     pic x(256)       value spaces.                 
       procedure division.                                            
                                                                      
          set pp to entry "kernel32"                                  
          set pp to entry "IsWow64Process"                            
          if pp = null                                                
             display "32-bit"                                         
          else                                                        
             call winapi "GetCurrentProcess" returning procid         
             call winapi "IsWow64Process"                             
                using by value procid                                 
                      by reference wowprocess                         
                returning wsbool                                      
             end-call                                                 
             if wowprocess = 0                                        
                display "32-bit"                                      
             else                                                     
                display "64-bit"                                      
             end-if                                                   
          end-if                                                      
        *> or                                                         
                                                                      
        *> the following environment variable will only be present on 
        *> 64-bit systems                                             
          display "ProgramW6432" upon environment-name                
          accept OS64Path from environment-value                      
          if OS64Path not = spaces                                    
             display "64-bit Windows"                                 
          else                                                        
             display "32-bit Windows"                                 
          end-if                                                      
                                                                      
          stop run.