Browse Source

Update the WinForms and WPF samples to create the URL protocol entries under HKEY_CURRENT_USER

pull/1902/head
Kévin Chalet 3 years ago
parent
commit
692eb73484
  1. 10
      sandbox/OpenIddict.Sandbox.WinForms.Client/Worker.cs
  2. 10
      sandbox/OpenIddict.Sandbox.Wpf.Client/Worker.cs

10
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);

10
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);

Loading…
Cancel
Save