make register function cleaner

This commit is contained in:
bluepilledgreat 2023-10-04 15:22:41 +01:00
parent ba031a645e
commit 9dc836f8f3

View File

@ -116,9 +116,10 @@ namespace Bloxstrap
public static void Register(string key, string name, string handler) public static void Register(string key, string name, string handler)
{ {
string handlerArgs = $"\"{handler}\" %1"; string handlerArgs = $"\"{handler}\" %1";
RegistryKey uriKey = Registry.CurrentUser.CreateSubKey($@"Software\Classes\{key}");
RegistryKey uriIconKey = uriKey.CreateSubKey("DefaultIcon"); using RegistryKey uriKey = Registry.CurrentUser.CreateSubKey($@"Software\Classes\{key}");
RegistryKey uriCommandKey = uriKey.CreateSubKey(@"shell\open\command"); using RegistryKey uriIconKey = uriKey.CreateSubKey("DefaultIcon");
using RegistryKey uriCommandKey = uriKey.CreateSubKey(@"shell\open\command");
if (uriKey.GetValue("") is null) if (uriKey.GetValue("") is null)
{ {
@ -126,15 +127,11 @@ namespace Bloxstrap
uriKey.SetValue("URL Protocol", ""); uriKey.SetValue("URL Protocol", "");
} }
if ((string?)uriCommandKey.GetValue("") != handlerArgs) if (uriCommandKey.GetValue("") as string != handlerArgs)
{ {
uriIconKey.SetValue("", handler); uriIconKey.SetValue("", handler);
uriCommandKey.SetValue("", handlerArgs); uriCommandKey.SetValue("", handlerArgs);
} }
uriKey.Close();
uriIconKey.Close();
uriCommandKey.Close();
} }
public static void RegisterRobloxPlace(string handler) public static void RegisterRobloxPlace(string handler)