diff --git a/Kiseki.Launcher.Windows/ProtocolHandler.cs b/Kiseki.Launcher.Windows/ProtocolHandler.cs index 57f0353..01b04e5 100644 --- a/Kiseki.Launcher.Windows/ProtocolHandler.cs +++ b/Kiseki.Launcher.Windows/ProtocolHandler.cs @@ -1,40 +1,38 @@ -using System.Windows; - using Microsoft.Win32; namespace Kiseki.Launcher.Windows { public class ProtocolHandler : IProtocolHandler { - public void Register(string handler) + public void Register(string key, string name, string handler) { string arguments = $"\"{handler}\" \"%1\""; - RegistryKey uri = Registry.CurrentUser.CreateSubKey(@"Software\Classes\kiseki"); - RegistryKey icon = uri.CreateSubKey("DefaultIcon"); - RegistryKey command = uri.CreateSubKey(@"shell\open\command"); + RegistryKey uriKey = Registry.CurrentUser.CreateSubKey(@$"Software\Classes\{key}"); + RegistryKey uriIconKey = uriKey.CreateSubKey("DefaultIcon"); + RegistryKey uriCommandKey = uriKey.CreateSubKey(@"shell\open\command"); - if (uri.GetValue("") is null) + if (uriKey.GetValue("") is null) { - uri.SetValue("", "URL: Kiseki Protocol"); - uri.SetValue("URL Protocol", ""); + uriKey.SetValue("", $"URL: {name} Protocol"); + uriKey.SetValue("URL Protocol", ""); } - if ((string?)command.GetValue("") != arguments) + if ((string?)uriCommandKey.GetValue("") != arguments) { - command.SetValue("", arguments); + uriCommandKey.SetValue("", arguments); } - uri.Close(); - icon.Close(); - command.Close(); + uriKey.Close(); + uriIconKey.Close(); + uriCommandKey.Close(); } - public void Unregister() + public void Unregister(string key) { try { - Registry.CurrentUser.DeleteSubKeyTree(@"Software\Classes\kiseki"); + Registry.CurrentUser.DeleteSubKeyTree(@$"Software\Classes\{key}"); } catch (Exception) { diff --git a/Kiseki.Launcher/Interfaces.cs b/Kiseki.Launcher/Interfaces.cs index 91af3d8..28b8a33 100644 --- a/Kiseki.Launcher/Interfaces.cs +++ b/Kiseki.Launcher/Interfaces.cs @@ -2,8 +2,8 @@ namespace Kiseki.Launcher { interface IProtocolHandler { - void Register(string handler); - void Unregister(); + void Register(string key, string name, string handler); + void Unregister(string key); } interface IMainWindow