使用 VBA 权限读取 Windows 7 上的注册表 [英] Read Registry on Windows 7 with VBA Permission

查看:85
本文介绍了使用 VBA 权限读取 Windows 7 上的注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一行代码在 Access 2007 和 Access 2010 中的 50 多台 PC(Vista 和 Windows 7 32 位和 64 位)上运行了多年.

 RegStr = fReturnRegKeyValue(HKEY_LOCAL_MACHINE, "Software\ThisApp\App", "Activation")

在一台带有 Access2010/VBA 模块(32 位)的特定 PC(Windows 7 64 位)上

上面的代码行没有看到注册表项.

当我将 HKEY_LOCAL_MACHINE 更改为 HKEY_CURRENT_USER 时,它工作正常.

 RegStr = fReturnRegKeyValue(HKEY_CURRENT_USER, "Software\ThisApp\App", "Activation")

解决方案

导致此类问题的一个可能原因是 注册表虚拟化,微软从 Vista 开始添加到 Windows.在 Windows 中启用 UAC(用户帐户控制)后,非特权用户仍然可以修改"系统范围的设置,例如 HKEY_LOCAL_MACHINE 注册表值,但这些更改仅针对该用户虚拟化",其他用户无法看到它们.

在这种情况下,一个用户可能运行了一个将设置保存到 HKEY_LOCAL_MACHINE 的应用程序.该用户将能够检索这些设置并正常运行应用程序,但另一个用户将无法看到这些 HKEY_LOCAL_MACHINE 设置,因为它们仅对创建它们的用户可见.

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")

解决方案

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.

这篇关于使用 VBA 权限读取 Windows 7 上的注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆