简体   繁体   English

HKEY_CURRENT_USER不会发生注册表重定向

[英]Registry redirection does not happen for HKEY_CURRENT_USER

I have the following code: 我有以下代码:

RegistryKey objRegKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\MySettings\\Dwm\\Preferences", true);

I have a registry key present under: HKEY_CURRENT_USER\\SOFTWARE\\MySettings\\Dwm\\Preferences and so this works fine. 我在以下位置存在注册表项: HKEY_CURRENT_USER\\SOFTWARE\\MySettings\\Dwm\\Preferences ,因此可以正常工作。

When I change the above code to read from local machine instead of current user: 当我更改以上代码以从本地计算机而不是当前用户读取时:

RegistryKey objRegKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\MySettings\\Dwm\\Preferences", true);

and create the following registry under: HKEY_LOCAL_MACHINE\\SOFTWARE\\MySettings\\Dwm\\Preferences 并在以下位置创建以下注册表: HKEY_LOCAL_MACHINE\\SOFTWARE\\MySettings\\Dwm\\Preferences

The code returns null. 该代码返回null。 I understand the reason being that due to registry redirection for 32 bit applications on a 64 bit OS, it tries to read the registry from: HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432NODE\\MySettings\\Dwm\\Preferences and since the registry does not exists, it returns null. 我了解原因是由于对64位OS上的32位应用程序进行注册表重定向,因此它尝试从以下位置读取注册表: HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432NODE\\MySettings\\Dwm\\Preferences并且由于注册表不存在,因此它返回null 。 The question is that why redirection only happens for HKEY_LOCAL_MACHINE and not for HKEY_CURRENT_USER ? 问题是,为什么仅对HKEY_LOCAL_MACHINE而不对HKEY_CURRENT_USER进行重定向?

Registry Redirection isn't a binary option - either present or not. 注册表重定向不是一个二进制选项-是否存在。 Sometimes you want both 32-bit and 64-bit applications to have the same "view" of (part of) the registry and in other cases you do not. 有时,您希望 32位和64位应用程序对注册表(的一部分)具有相同的“视图”,而在其他情况下,则不需要。

That's why the specific keys affected by redirection are documented. 这就是为什么记录了受重定向影响的特定的原因。 HKEY_CURRENT_USER itself is shared, as is HKEY_CURRENT_USER\\Software . HKEY_CURRENT_USER本身是共享的, HKEY_CURRENT_USER\\Software也是共享的。 However, HKEY_CURRENT_USER\\Software\\Classes\\CLSID , which includes COM component registration data (which is necessarily 32/64 bit split) does perform redirection. 但是, HKEY_CURRENT_USER\\Software\\Classes\\CLSID包含COM组件注册数据(必须进行32/64位拆分),它确实执行重定向。

Or, to put it another way, if registry redirection was universal, you wouldn't need all of this convolution involving Wow6432Node , etc. You'd just have a 32-bit registry and a 64-bit registry. 或者,换句话说,如果注册表重定向是通用的,则不需要所有涉及Wow6432Node等的卷积。您只需拥有32位注册表和64位注册表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将注册表写入hkey_current_user而不是hkey_users - write registry to hkey_current_user instead of hkey_users 模拟获取用户 HKEY_CURRENT_USER 不起作用? - Impersonation to get user HKEY_CURRENT_USER does not work? 从注册表读取HKEY_CURRENT_USER的子项将返回HKEY_USERS子项的值 - Reading subkeys of HKEY_CURRENT_USER from Registry returns HKEY_USERS subkeys value 有没有一种方法可以创建注册表子项并在HKEY_CURRENT_USER \\下设置它的值…\\ FEATURE_BROWSER_EMULATION \\ - Is there a way to create a registry SubKey and set it's value under HKEY_CURRENT_USER\ … \FEATURE_BROWSER_EMULATION\ 无法写入HKEY_CURRENT_USER - Unable to write to HKEY_CURRENT_USER 在IIS下读取HKEY_CURRENT_USER - Reading HKEY_CURRENT_USER under IIS 比较HKEY_USER和HKEY_CURRENT_USER - Comparing the HKEY_USER and HKEY_CURRENT_USER 如何启用 ASP.NET 对注册表项“HKEY_CURRENT_USER\\Software\\myAppKey\\subdir”的写访问权限? - How to enable ASP.NET write access to the registry key 'HKEY_CURRENT_USER\Software\myAppKey\subdir'? winform C#,不确定为什么要修改HKEY_CURRENT_USER注册表项 - winform c#, Unsure why HKEY_CURRENT_USER registry key modification is requiring elevation 拒绝访问注册表项'HKEY_CURRENT_USER \\ Software \\ Policies \\ Microsoft \\ office \\ 15.0 \\ outlook' - Access to the registry key 'HKEY_CURRENT_USER\Software\Policies\Microsoft\office\15.0\outlook' is denied
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM