none
Windows UWP Application RegistryKey Failed RRS feed

  • Question

  •  // 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);
                }
            }

                    
    Friday, August 2, 2019 8:13 AM

Answers

  • Hi XinYueVR, 

    Thank you for posting here.

    I make a test on my side based on you code, but I don’t get an exception in ‘RegistryKey myKey = CurrentUser.CreateSubKey(…);’.

    I get the following exception in ‘myKey.SetValue ()’.

    Then I change the value in the method and avoid the exception.

    Could you provide more details about your exception? It will help us to analyze your problem.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.




    Monday, August 5, 2019 8:37 AM
    Moderator

All replies

  • Hi XinYueVR, 

    Thank you for posting here.

    I make a test on my side based on you code, but I don’t get an exception in ‘RegistryKey myKey = CurrentUser.CreateSubKey(…);’.

    I get the following exception in ‘myKey.SetValue ()’.

    Then I change the value in the method and avoid the exception.

    Could you provide more details about your exception? It will help us to analyze your problem.

    We are waiting for your update.

    Best Regards,

    Xingyu Zhao


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.




    Monday, August 5, 2019 8:37 AM
    Moderator
  • Thank you
    Tuesday, August 6, 2019 1:47 AM