Skip to content

Commit 357cacb

Browse files
committed
Update ContextMenu.cs
Fixed "AppliseTo" - context menu should now only show on proper filetypes Added automatic context menu updating
1 parent ba45385 commit 357cacb

1 file changed

Lines changed: 17 additions & 5 deletions

File tree

Repackinator.Core/Shell/ContextMenu.cs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using Microsoft.Win32;
22
using Repackinator.Core.Helpers;
3+
using Repackinator.Core;
4+
using System.Runtime.InteropServices.Marshalling;
35

46
namespace Repackinator.Core.Shell
57
{
@@ -23,13 +25,25 @@ public static bool RegisterContext()
2325
{
2426
return false;
2527
}
26-
var exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{AppDomain.CurrentDomain.FriendlyName}.exe");
2728

29+
using var tempKey = Registry.ClassesRoot.OpenSubKey($"*\\shell\\Repackinator");
30+
if ((string?)tempKey?.GetValue("Version") != Version.Value)
31+
{
32+
tempKey?.Close();
33+
UnregisterContext();
34+
}
35+
else
36+
{
37+
tempKey?.Close();
38+
}
39+
40+
var exePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"{AppDomain.CurrentDomain.FriendlyName}.exe");
2841
using var key = Registry.ClassesRoot.CreateSubKey($"*\\shell\\Repackinator");
2942

30-
key.SetValue("AppliseTo", ".iso OR .cci");
43+
key.SetValue("AppliesTo", ".iso OR .cci OR .zip OR .rar OR .7z");
3144
key.SetValue("MUIVerb", "Repackinator");
3245
key.SetValue("SubCommands", string.Empty);
46+
key.SetValue("Version", Version.Value);
3347

3448
RegisterSubMenu(key, "01ConvertToISO", "Convert To ISO", $"\"{exePath}\" -i=\"%L\" -a=convert -w");
3549
RegisterSubMenu(key, "02ConvertToISOScrub", "Convert To ISO (Scrub)", $"\"{exePath}\" -i=\"%L\" -a=convert -s=Scrub -w");
@@ -39,8 +53,6 @@ public static bool RegisterContext()
3953
RegisterSubMenu(key, "05ConvertToCCIScrub", "Convert To CCI (Scrub)", $"\"{exePath}\" -i=\"%L\" -a=convert -s=Scrub -c=CCI -w");
4054
RegisterSubMenu(key, "06ConvertToCCITrimScrub", "Convert To CCI (TrimScrub)", $"\"{exePath}\" -i=\"%L\" -a=convert -s=TrimScrub -c=CCI -w");
4155

42-
//
43-
4456
RegisterSubMenu(key, "10CompareSetFirst", "Compare Set First", $"\"{exePath}\" -f=\"%L\" -a=compare");
4557
RegisterSubMenu(key, "11CompareFirstWith", "Compare First With", $"\"{exePath}\" -s=\"%L\" -a=compare -c -w");
4658
RegisterSubMenu(key, "12Info", "Info", $"\"{exePath}\" -i=\"%L\" -a=info -w");
@@ -56,7 +68,7 @@ public static bool UnregisterContext()
5668
{
5769
return false;
5870
}
59-
Registry.ClassesRoot.DeleteSubKeyTree("*\\shell\\Repackinator");
71+
Registry.ClassesRoot.DeleteSubKeyTree("*\\shell\\Repackinator", false);
6072
return true;
6173
}
6274
}

0 commit comments

Comments
 (0)