Read The Registry Using Win 8 App?

跟風遠走 提交于 2019-12-24 16:42:43

问题


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.

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.


回答1:


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):

[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.



来源:https://stackoverflow.com/questions/17050394/read-the-registry-using-win-8-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!