问题
I have a line of code that has worked flawlessly for years on 50+ PCs (Vista & Windows 7 32 & 64 bit) in Access 2007 and Access 2010.
RegStr = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, "Software\ThisApp\App", "Activation")
On one specific PC (Windows 7 64bit) with An Access2010/VBA module (32 bit)
The line of code above does not see the registry key.
When I change HKEY_LOCAL_MACHINE to HKEY_CURRENT_USER,it works fine.
RegStr = fReturnRegKeyValue(HKEY_CURRENT_USER, "Software\ThisApp\App", "Activation")
回答1:
One possible cause of issues like this is the registry virtualization that Microsoft added to Windows starting with Vista. When UAC (User Account Control) is enabled in Windows, non-privileged users can still "modify" system-wide settings like HKEY_LOCAL_MACHINE registry values, but those changes are "virtualized" for that user only and other users cannot see them.
In this case, one user may have run an application which saved settings to HKEY_LOCAL_MACHINE. That user will be able to retrieve those settings and run the application as normal, but another user won't be able to see those HKEY_LOCAL_MACHINE settings because they are only visible to the user that created them.
来源:https://stackoverflow.com/questions/17819921/read-registry-on-windows-7-with-vba-permission