Group: Registry - Library: advapi32
Reading VFP settings from the Windows Registry
How to save registry key including its subkeys and values to a file
Obtaining current Internet Explorer browser version and UserAgent
Saving local machine ODBC Registry Entries to XML file
How to obtain Content-Type value for a file type from the System Registry
Class library providing access to the System Registry
LONG RegOpenKeyEx(
HKEY hKey, // handle to open key
LPCTSTR lpSubKey, // subkey name
DWORD ulOptions, // reserved
REGSAM samDesired, // security access mask
PHKEY phkResult // handle to open key
);
DECLARE INTEGER RegOpenKeyEx IN advapi32;
INTEGER hKey,;
STRING lpSubKey,;
INTEGER ulOptions,;
INTEGER samDesired,;
INTEGER @ phkResult
hKey [in] Handle to a currently open key or a predefined reserved handle value.
lpSubKey [in] Pointer to a null-terminated string containing the name of the subkey to open.
ulOptions Reserved; must be zero.
samDesired [in] An access mask that specifies the desired access rights to the key.
phkResult [out] Pointer to a variable that receives a handle to the opened key.
If the function succeeds, the return value is 0 (ERROR_SUCCESS). Otherwise, the return value is a nonzero error code.
When you no longer need the handle returned by this function, call the RegCloseKey function to close it.
June 2, 2010. Contributed by Igor Nikiforov:
Under Windows 2008 Server 64-bit, a call to RegOpenKeyEx returns error code 2 (ERROR_FILE_NOT_FOUND) for some keys.
Example:
RegOpenKeyEx(HKEY_LOCAL_MACHINE ,;
[SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\ ... ;
... \InstallProperties], 0, ;
KEY_READ, @hKey)
Changing samDesired input parameter from KEY_READ to ( KEY_READ | KEY_WOW64_64KEY ) resolves the issue.
RegOpenKeyEx(HKEY_LOCAL_MACHINE , ;
[SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\ ... ;
... \InstallProperties], 0, ;
BITOR(KEY_READ, KEY_WOW64_64KEY), @hKey)
Find more in Registry Key Security and Access Rights article on MSDN web site.