How to access registry key in a UWP app?

北慕城南 提交于 2019-11-26 17:12:37

问题


I would like to access windows10 registry key by a UWP app. key as: \HKEY_LOCAL_MACHINE\SOFTWARE\MyCompanyName\MyName I can not find any function call to accomplish it. Please indicate me How to do it? Thank you,


回答1:


You can read registry values from a Win32 runFullTrust background process launched from a UWP application, and you can write values in the HKEY_LOCAL_MACHINE hive from an "elevated" Win32 application launched from that runFullTrust process.

These techniques are powerful and using them in a UWP app deployed from the Windows Store requires special scrutiny and permission from Microsoft. The techniques are used by OEMs, but not exclusively restricted to them. If you have a good reason and are able to explain it, you're likely to get approval.

I have written a sample and article that shows exactly how to do this, and you may find it here.




回答2:


If your app is a pure UWP app, this is not possible. UWP apps were built with the goal of being lightweight and avoid registry as much as possible, so your app cannot access the registry at all (although some registry keys are created by the system when the app is installed, like URI protocol registration, etc.).

If you really needed to access the registry and don't need to publish your app on Microsoft Store, you could implement a Brokered Windows Runtime Component. This allows you to call on full-trust .NET Framework libraries from UWP which in turn can access the registry. However, app using Brokered Components will not pass certification.

Finally, if your app is a UWP Desktop Bridge app, you have access to the registry - see documentation.



来源:https://stackoverflow.com/questions/48899692/how-to-access-registry-key-in-a-uwp-app

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