From 692eb734845a6f724410d7a527851869da203c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Chalet?= Date: Tue, 17 Oct 2023 14:44:13 +0200 Subject: [PATCH] Update the WinForms and WPF samples to create the URL protocol entries under HKEY_CURRENT_USER --- sandbox/OpenIddict.Sandbox.WinForms.Client/Worker.cs | 10 +++++----- sandbox/OpenIddict.Sandbox.Wpf.Client/Worker.cs | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) 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);