使用 Win 8 App 读取注册表? [英] Read The Registry Using Win 8 App?

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

问题描述

我正在尝试查看是否可以从 Windows 8 应用程序读取注册表.我通常可以使用 Registry.GetValue() 但在创建 Win 8 应用程序时我没有那个选项.进行一些挖掘表明 Registry.GetValue() 属于 Microsoft.Win32 命名空间,该命名空间在 Win 8 应用引用属性选项卡中不可用.

I'm trying to see if it's possible to read the registry from a Windows 8 app. I can usually use Registry.GetValue() but I don't have that option when creating the Win 8 app. Doing some digging shows that the Registry.GetValue() belongs to the Microsoft.Win32 namespace which isn't available in the Win 8 app references properties tab.

我进行了一些谷歌搜索,但找不到任何具体的证据表明您无法阅读注册表.我担心由于沙盒 Win 8 应用程序,我将无法执行此操作.

I did some googling but I couldn't find any concrete evidence that you cannot read the registry. I fear that I won't be able to do this because of sandboxing Win 8 apps.

推荐答案

如果确实需要,可以使用互操作服务来实现.

If you really need to, you can do that by using interop services.

因此导入您需要的 WinAPI 函数(您可以从 PInvoke 获取签名.净):

So import the WinAPI functions you need (you can get the signatures from PInvoke.net):

[DllImport("advapi32.dll", CharSet = CharSet.Unicode)]
public static extern int RegOpenKeyEx(UIntPtr hKey, string lpSubKey,
      uint ulOptions, int samDesired, out UIntPtr phkResult);

并为它们制作自己的包装器.

And make your own wrapper around them.

但据我所知,这是不允许的,您的应用将无法通过认证.

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

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