什么是一些替代RegistryKey.OpenBaseKey在.NET 3.5? [英] What are some alternatives to RegistryKey.OpenBaseKey in .NET 3.5?

查看:1993
本文介绍了什么是一些替代RegistryKey.OpenBaseKey在.NET 3.5?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直工作在一个安装包,并使用<一个href="http://msdn.microsoft.com/en-us/library/microsoft.win32.registrykey.openbasekey(v=vs.100).aspx"相对=nofollow> RegistryKey.OpenBaseKey 与自定义操作的工作,无论是开放的,从64位注册表或从MSI软件包的32位注册表中添加/删除键/,但是这需要我在目标计算机上安装.NET Framework 4运行我的安装,使用引导程序或别的东西之前,因为 OpenBaseKey 的仅是.NET Framework中的介绍4.理想的情况下,我想只是针对.NET框架3.5并且仍然能够修改或者像在64位或32位的注册表配置的 OpenBaseKey 的;那么我就不需要.NET 4和安装它的开销。

I've been working on an installer package and using RegistryKey.OpenBaseKey to work with custom actions that either open and add/remove keys to/from the 64-bit registry or the 32-bit registry from an MSI package, but this requires me to install .NET Framework 4 on the target machine before running my installer, using a bootstrapper or something else, because OpenBaseKey was only introduced in .NET Framework 4. Ideally, I would like to target just .NET Framework 3.5 and still be able to modify either the 64-bit or 32-bit registry hives like in OpenBaseKey; then I wouldn't need .NET 4 and the overhead of installing it.

是否有替代品的 OpenBaseKey 的对我们这些谁不喜欢让.NET 4 prerequisite?类似P /调用一定WinAPI的方法来揭开这一关,也许?我不知道它会采取什么。

Are there alternatives to OpenBaseKey for those of us who would not like to make .NET 4 a prerequisite? Something like P/Invoking a certain WinAPI method to kick this off, perhaps? I'm not sure what it would take.

推荐答案

对于.NET版本早于4版本没有任何架构的API,允许访问备用注册表意见。为了访问备用的观点,你必须调用本机API RegOpenKeyEx的通过的 KEY_WOW64_32KEY KEY_WOW64_64KEY 标记为合适。

For .NET versions earlier than version 4 there is no framework API that allows access to alternate registry views. In order to access alternate views you must call the native API RegOpenKeyEx passing one of the KEY_WOW64_32KEY or KEY_WOW64_64KEY flags as appropriate.

常见的方式来做到这一点与C ++ / CLI混合模式组件,或使用的P / Invoke 。然而,这是不是很好玩的。注册表API是一些更难以使用,因为它们支持多种数据类型的值。

Common ways to do this are with C++/CLI mixed mode assemblies, or using P/Invoke. However, this is not very much fun at all. The registry APIs are some of the more awkward to use, because they support multiple data types for values.

这篇关于什么是一些替代RegistryKey.OpenBaseKey在.NET 3.5?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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