How to access registry key in a UWP app?
Asked Answered
L

2

5

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,

Lid answered 21/2, 2018 at 6:45 Comment(0)
S
6

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.

Saldana answered 23/3, 2019 at 15:27 Comment(0)
B
9

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.

Bloke answered 21/2, 2018 at 8:15 Comment(0)
S
6

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.

Saldana answered 23/3, 2019 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.