读64位注册从32位应用程序 [英] Reading 64bit Registry from a 32bit application

查看:192
本文介绍了读64位注册从32位应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个编译值为anycpu C#单元测试项目。我们构建服务器是一个64位的机器,并安装了SQL防爆preSS实例中的64位。

I have a c# unit test project that is compiled for AnyCPU. Our build server is a 64bit machine, and has a 64bit SQL Express instance installed.

该测试项目使用code类似于下列标识的.MDF文件的路径:

The test project uses code similar to the following to identify the path to the .MDF files:

    private string GetExpressPath()
    {
        RegistryKey sqlServerKey = Registry.LocalMachine.OpenSubKey( @"SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL" );
        string sqlExpressKeyName = (string) sqlServerKey.GetValue( "SQLEXPRESS" );
        RegistryKey sqlInstanceSetupKey = sqlServerKey.OpenSubKey( sqlExpressKeyName + @"\Setup" );
        return sqlInstanceSetupKey.GetValue( "SQLDataRoot" ).ToString();
    }

这code正常工作,我们的32位工作站,并没有工作,确定了构建服务器上,直到我最近启用了code覆盖分析与NCover。由于NCover采用的是32位COM组件,测试运行(加利奥)作为运行32位程序。

This code works fine on our 32bit workstations, and did work ok on the build server until I recently enabled code coverage analysis with NCover. Because NCover uses a 32bit COM component, the test runner (Gallio) runs as a 32bit process.

检查注册表,就在

HKEY_LOCAL_MACHINE \ SOFTWARE \ Wow6432Node \微软\ Microsoft SQL Server的

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SQL Server

有没有办法在32位模式下运行的应用程序访问Wow6432Node外注册表?

Is there a way for an application running in 32bit mode to access the registry outside Wow6432Node?

推荐答案

您已经创建/打开注册表项时使用的KEY_WOW64_64KEY参数。但AFAIK这是不可能的登记类,但直接使用API​​,只有当。

you have to use the KEY_WOW64_64KEY param when creating/opening the registry key. But AFAIK that's not possible with the Registry class but only when using the API directly.

可能有助于让你开始。

This might help to get you started.

这篇关于读64位注册从32位应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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