Using the RegOpenKeyEx windows API to read registry entries:
#DEFINE HKEY_CURRENT_USER 0x80000001
#DEFINE HKEY_LOCAL_MACHINE 0x80000002
#DEFINE HKEY_USERS 0x80000003
#DEFINE KEY_READ 0x20019
DECLARE INTEGER RegOpenKeyEx IN advapi32;
INTEGER hKey,;
STRING lpSubKey,;
INTEGER ulOptions,;
INTEGER samDesired,;
INTEGER @ phkResult
LOCAL nHKey,lcSubKey
nHKey=0
lcSubKey="SOFTWARE\ATI"
? RegOpenKeyEx(HKEY_LOCAL_MACHINE,lcSubKey,0,KEY_READ,@nhKey)
See attached screenshot. It succeeds and fails for no discernible reason:
lcSubKey="SOFTWARE\2X" returns 2 - failure
lcSubKey="SOFTWARE\Adobe" returns 0 - Success
lcSubKey="SOFTWARE\AGEIA Technologies" returns 0 - Success
lcSubKey="SOFTWARE\AMD" returns 2 - failure
lcSubKey="SOFTWARE\ATI" returns 0 - Success
lcSubKey="SOFTWARE\ATI Technologies" returns 0 - Success
and so on and so on. I've verified these registry entries are properly inheriting permissions.
Curiously, if I instead use the HKEY_CURRENT_USER hive and query that section of the registry the RegOpenKeyEx function always returns 0 Success.
I'm at a loss. Any ideas?
Brandon Harker
Sebae Data Solutions