RegOpenFlags

Specifies the registry view of the various Reg[..] functions.

Syntax:

RegOpenFlags(flag)

Parameters:

(i) flag a flag which specifies which view of the registry the various Reg[..] functions will see.

Returns:

(i) previous value. Note: under certain circumstances this function may also return the value 2 ( maintained for backward compatibility with older versions of WinBatch).

 

This function lets you specify an alternate view of the registry for Reg[..] functions which create, open, and delete registry keys, when running on (or accessing) a 64-bit Windows platform.

Flags

Meaning

0

32-bit view under Win32, 64-bit view under WOW64 (default)

32

32-bit view

64

64-bit view

 

RegOpenFlags is basically no-opt on 32-bit Windows.

 

*IMPORTANT*

 

Registry Redirection
To prevent 32-bit registry settings from overwriting the 64-bit registry settings, computers that are running an x64-based version of

Windows store the settings for 32-bit programs in a new branch in the registry. The registry redirection process enables program installations and program configuration settings to access the 'correct' registry sub key without user intervention.

 

32-bit programs and 64-bit programs that are running on an x64-based version of Windows operate in different modes and use the following

sections in the registry:

 

• Native mode 64-bit programs run in Native mode and access keys and values that are stored in the following registry sub key:
 

HKEY_LOCAL_MACHINE\Software

 

• 32-bit programs (like WinBatch) run in WOW64 mode and access keys and values that are stored in the following registry sub key:
 

HKEY_LOCAL_MACHINE\Software\WOW6432node

 

2 simple rules to accessing the registry on 64-bit systems:

  1. NEVER directly access keys stored under WOW6432node.
     

  2. If you do want access something under WOW6432node, just set the registry view to 32-bit using RegOpenFlags(32) and specify the key/value without using 'WOW6432node' in the registry path. (In other words use it 's regular 32-bit key/value.)
     

You can launch the 32-bit version of Registry Editor on a 64-bit Windows platform using the following command line:

 

C:\Windows\syswow64\regedit.exe

 

Example:


;64-bit view
RegOpenFlags(64)
See Also:

RegOpenKeyEx, RegCreateKey, RegCloseKey, RegDeleteKey, RegSetValue, RegQueryValue, RegQueryKey, and the section on Registration Database Operations