diff --git a/sandbox/OpenIddict.Sandbox.WinForms.Client/Worker.cs b/sandbox/OpenIddict.Sandbox.WinForms.Client/Worker.cs index a1fd76cc..d71c4aca 100644 --- a/sandbox/OpenIddict.Sandbox.WinForms.Client/Worker.cs +++ b/sandbox/OpenIddict.Sandbox.WinForms.Client/Worker.cs @@ -24,18 +24,18 @@ public class Worker : IHostedService // Create the registry entries necessary to handle URI protocol activations. // - // Note: the application MUST be run once as an administrator for this to work, - // so this should typically be done by a dedicated installer or a setup script. - // // Alternatively, the application can be packaged and use windows.protocol to // register the protocol handler/custom URI scheme with the operation system. try { - root = Registry.ClassesRoot.OpenSubKey("com.openiddict.sandbox.winforms.client"); + // Note: this sample creates the entry under the current user account (as it doesn't + // require administrator rights), but the registration can also be added globally + // in HKEY_CLASSES_ROOT (in this case, it should be added by a dedicated installer). + root = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Classes\\com.openiddict.sandbox.winforms.client"); if (root is null) { - root = Registry.ClassesRoot.CreateSubKey("com.openiddict.sandbox.winforms.client"); + root = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Classes\\com.openiddict.sandbox.winforms.client"); root.SetValue(string.Empty, "URL:com.openiddict.sandbox.winforms.client"); root.SetValue("URL Protocol", string.Empty); diff --git a/sandbox/OpenIddict.Sandbox.Wpf.Client/Worker.cs b/sandbox/OpenIddict.Sandbox.Wpf.Client/Worker.cs index 17ca7d96..b425480c 100644 --- a/sandbox/OpenIddict.Sandbox.Wpf.Client/Worker.cs +++ b/sandbox/OpenIddict.Sandbox.Wpf.Client/Worker.cs @@ -24,18 +24,18 @@ public class Worker : IHostedService // Create the registry entries necessary to handle URI protocol activations. // - // Note: the application MUST be run once as an administrator for this to work, - // so this should typically be done by a dedicated installer or a setup script. - // // Alternatively, the application can be packaged and use windows.protocol to // register the protocol handler/custom URI scheme with the operation system. try { - root = Registry.ClassesRoot.OpenSubKey("com.openiddict.sandbox.wpf.client"); + // Note: this sample creates the entry under the current user account (as it doesn't + // require administrator rights), but the registration can also be added globally + // in HKEY_CLASSES_ROOT (in this case, it should be added by a dedicated installer). + root = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Classes\\com.openiddict.sandbox.wpf.client"); if (root is null) { - root = Registry.ClassesRoot.CreateSubKey("com.openiddict.sandbox.wpf.client"); + root = Registry.CurrentUser.CreateSubKey("SOFTWARE\\Classes\\com.openiddict.sandbox.wpf.client"); root.SetValue(string.Empty, "URL:com.openiddict.sandbox.wpf.client"); root.SetValue("URL Protocol", string.Empty);