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
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:
01605462
Views:
62
This message has been marked as the solution to the initial question of the thread.
Likes (1)
>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?


It turns out that when a 32bit application is accessing the registry on a 64bit system, when the app specifies SOFTWARE\Something the RegOpenKeyEx is actually returning SOFTWARE\Wow6432Node\Something

More info here:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724878(v=vs.85).aspx

See KEY_WOW64_32KEY and KEY_WOW64_64KEY
Brandon Harker
Sebae Data Solutions
Previous
Reply
Map
View

Click here to load this message in the networking platform