简体   繁体   中英

C# updating or adding value to registry

Why this code is not working

    RegistryKey baseKey = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64);
RegistryKey key = baseKey.OpenSubKey(REGISTY_NOTIFICATION_ROOT_PATH, true);
    key.SetValue("NOC_GLOBAL_SETTING_ALLOW_TOASTS_ABOVE_LOCK", bytes, RegistryValueKind.DWord);

After this i am calling close to flush the changes.

key.Close();

Tried baseKey .Close(); also but no luck

Ideally it should update the notification setting but it is not. Is there any other way to update DWORD value in c#

Just to make it clear

I am using AppServiceConnection to actually communicate with win32 app and my win32 app is actual updating the Registry. My question is above code is not updating the registry value, It's not throwing any error but not updating the value also.

Thank

You can't access registry with uwp directly. Please check this case reply

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

For details steps please refer UWP sends request to desktop extension blog. This is code sample .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM