Windows UWP Application RegistryKey Failed

  • Thread starter Thread starter XinYueVR
  • Start date Start date
X

XinYueVR

Guest
// app.manifest Settings requireAdministrator

<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">

<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />


</requestedPrivileges>
</security>
</trustInfo>

//........

//Page Code


public SettingsPage()
{
InitializeComponent();


using (RegistryKey CurrentUser = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser, RegistryView.Registry64))
{
RegistrySecurity userSecurity = new RegistrySecurity();
RegistryAccessRule userRule = new RegistryAccessRule("Everyone", RegistryRights.FullControl, AccessControlType.Allow);
userSecurity.AddAccessRule(userRule);
RegistryKey myKey = CurrentUser.CreateSubKey(@"Software\\DefaultCompany\\HTML2", RegistryKeyPermissionCheck.ReadWriteSubTree, userSecurity); //is Failed here
myKey.SetValue("Version", 07024037587, RegistryValueKind.DWord);
}
}

Continue reading...
 
Back
Top