/
FileTypeReg.cs
49 lines (43 loc) · 1.46 KB
/
FileTypeReg.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Redate
{
static class FileTypeReg
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "So don't care")]
internal static void Register()
{
string appPath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(@".redate", true))
{
key.SetValue("", "SGR.Redate.File");
}
using (RegistryKey key = Registry.ClassesRoot.CreateSubKey(@"SGR.Redate.File", true))
{
key.SetValue("", "Redate State Definition File");
using (RegistryKey iconKey = key.CreateSubKey("DefaultIcon", true))
{
iconKey.SetValue("", "\"" + appPath + "\",0");
}
using (RegistryKey shellKey = key.CreateSubKey("shell", true))
{
shellKey.SetValue("", "open");
using (RegistryKey openKey = shellKey.CreateSubKey(@"open\command", true))
{
openKey.SetValue("", "\"" + appPath + "\" run \"%1\"");
}
}
}
}
[System.Diagnostics.CodeAnalysis.SuppressMessage("Interoperability", "CA1416:Validate platform compatibility", Justification = "So don't care")]
internal static void Unregister()
{
Registry.ClassesRoot.DeleteSubKeyTree(@".redate", false);
Registry.ClassesRoot.DeleteSubKeyTree(@"SGR.Redate.File", false);
}
}
}