为注册表项启用注册表重定向 [英] Enabling Registry Redirection for a Registry Key

查看:156
本文介绍了为注册表项启用注册表重定向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发VC ++项目.它是一个32位应用程序.在先决条件检查中,我正在从该项目中访问一些注册表项/值.我的应用程序在32位计算机上工作正常.在64位计算机上,先决条件检查失败.我正在尝试访问HKLM \ SOFTWARE \ Microsoft \ Microsoft Operations Manager下的注册表项,如下所示:

regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE \ Microsoft \ Microsoft SQL Server \ Instance Names \ RS",true);

在64位计算机上,代码在HKLM \ SOFTWARE \ Wow6432Node \ SOFTWARE \ Microsoft \ Microsoft SQL Server \ Instance Names \ RS下检查,其中不存在密钥.

我试图禁用注册表重定向,但是没有运气.取消重定向的代码是


类型type = typeof(RegistryKey);

FieldInfo fi = type.GetField("hkey",BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance);

SafeHandle句柄=(SafeHandle)fi.GetValue(regKey);

IntPtr realHandle = handle.DangerousGetHandle();

int errorCode = RegDisableReflectionKey(handle.DangerousGetHandle());

I am developing VC++ Project. It is a 32-bit application. In Prerequisites check, I am accessing some registry keys/values from this Project. My application is working fine on 32-bit machine. On 64-bit machine, prerequisities check is failing. I am trying to access a registry key under HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager as below:

regKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\RS", true);

On 64-bit machine, the code is checking under HKLM\SOFTWARE\Wow6432Node\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\RS, where the key is not present.

I tried to Disable registry redirection but with no luck. The code for Disbaling Redirection is


Type type = typeof(RegistryKey);

FieldInfo fi = type.GetField("hkey", BindingFlags.Static | BindingFlags.NonPublic | BindingFlags.Instance);

SafeHandle handle = (SafeHandle)fi.GetValue(regKey);

IntPtr realHandle = handle.DangerousGetHandle();

int errorCode = RegDisableReflectionKey(handle.DangerousGetHandle());

推荐答案

运行示例时"errorCode"的值是什么?
What is the value of "errorCode" when running your sample ?


errorCode的值为0.应为ERROR_SUCCESS.如果我在这里误解了任何内容,请纠正我.
The value of errorCode is 0. It should be ERROR_SUCCESS. Please correct me if I''ve misunderstood anything here.


我正在尝试找到我们也可以做到的方法!
如果您发现有其他目的,请尝试在此处写一些东西:-D.
如果有事我会打电话给你!
再见
I''m trying to find how we can do too!!
If you find something on this purpose try to write somthing here please :-D .
I call you if I fing anything!!
See you


这篇关于为注册表项启用注册表重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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