34 string appPath = Process.GetCurrentProcess().MainModule?.FileName;
35 if (
string.IsNullOrEmpty(appPath)) {
39 string friendlyAppName =
40 $
"{LanguageControl.Get("Usual
", "gameName
")} {ModsManager.ShortGameVersion} - API {ModsManager.APIVersionString}";
41 string command = $
"\"{appPath}\" \"%1\"";
43 using (RegistryKey progKey = Registry.CurrentUser.CreateSubKey(
$@"Software\Classes\{ProgIdBase}{extension}")) {
44 if (progKey ==
null) {
49 progKey.SetValue(
"FriendlyAppName", friendlyAppName);
51 using (RegistryKey iconKey = progKey.CreateSubKey(
"DefaultIcon")) {
52 iconKey?.SetValue(
"", $
"{appPath},0");
54 using (RegistryKey commandKey = progKey.CreateSubKey(
@"shell\open\command")) {
55 if (commandKey ==
null) {
59 commandKey.SetValue(
"", command);
62 using (RegistryKey openWithKey = Registry.CurrentUser.CreateSubKey(
63 $@"Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\{extension}\OpenWithProgids"
65 if (openWithKey ==
null) {
69 openWithKey.SetValue($
"{ProgIdBase}{extension}", Array.Empty<
byte>(), RegistryValueKind.None);
72 SHChangeNotify(0x08000000, 0x0000, IntPtr.Zero, IntPtr.Zero);
75 Log.
Error($
"{LanguageControl.Get(fName, "5
")}\n{e.Message}");
141 static extern void SHChangeNotify(uint wEventId, uint uFlags, IntPtr dwItem1, IntPtr dwItem2);