Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
RegOpenKeyEx Failing on HKLM
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
RegOpenKeyEx Failing on HKLM
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01605461
Message ID:
01605461
Views:
40
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
Next
Reply
Map
View

Click here to load this message in the networking platform