[英]Read The Registry Using Win 8 App?
I'm trying to see if it's possible to read the registry from a Windows 8 app. 我试图看看是否可以从Windows 8应用程序中读取注册表。 I can usually use Registry.GetValue() but I don't have that option when creating the Win 8 app.
我通常可以使用Registry.GetValue(),但在创建Win 8应用程序时我没有这个选项。 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.
进行一些挖掘表明Registry.GetValue()属于Microsoft.Win32命名空间,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.
我担心因为沙盒Win 8应用程序而无法做到这一点。
If you really need to, you can do that by using interop services. 如果您真的需要,可以通过使用互操作服务来实现。
So import the WinAPI functions you need (you can get the signatures from PInvoke.net ): 因此,导入您需要的WinAPI函数(您可以从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. 并围绕它们制作自己的包装。
But as far as I know, that's not allowed and your app won't pass the certification. 但据我所知,这是不允许的,您的应用程序将无法通过认证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.