feat: implement IProtocolHandler

This commit is contained in:
rjindael 2023-07-28 06:25:15 -07:00
parent 03769b50e8
commit dc0e6a1362
No known key found for this signature in database
GPG Key ID: D069369C906CCF31
2 changed files with 37 additions and 4 deletions

View File

@ -1,15 +1,48 @@
using System.Windows;
using Microsoft.Win32;
namespace Kiseki.Launcher.Windows
{
public class ProtocolHandler : IProtocolHandler
{
public void Register()
public void Register(string handler)
{
throw new NotImplementedException();
string arguments = $"\"{handler}\" \"%1\"";
RegistryKey uri = Registry.CurrentUser.CreateSubKey(@"Software\Classes\kiseki");
RegistryKey icon = uri.CreateSubKey("DefaultIcon");
RegistryKey command = uri.CreateSubKey(@"shell\open\command");
if (uri.GetValue("") is null)
{
uri.SetValue("", "URL: Kiseki Protocol");
uri.SetValue("URL Protocol", "");
}
if ((string?)command.GetValue("") != arguments)
{
command.SetValue("", arguments);
}
uri.Close();
icon.Close();
command.Close();
}
public void Unregister()
{
throw new NotImplementedException();
try
{
Registry.CurrentUser.DeleteSubKeyTree(@"Software\Classes\kiseki");
}
catch (Exception)
{
// Key doesn't exist (and why are we here?)
#if DEBUG
throw;
#endif
}
}
}
}

View File

@ -2,7 +2,7 @@ namespace Kiseki.Launcher
{
interface IProtocolHandler
{
void Register();
void Register(string handler);
void Unregister();
}