From e1af4003f7f53811be5997eaa532880c4bf136d1 Mon Sep 17 00:00:00 2001 From: cjee21 <77721854+cjee21@users.noreply.github.com> Date: Mon, 18 Nov 2024 21:01:56 +0800 Subject: [PATCH] Windows GUI: Fix shell extension registries --- Source/Common/Preferences.cpp | 8 ++++---- Source/Install/MediaInfo_Extensions.nsh | 22 +++++++++++++++------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Source/Common/Preferences.cpp b/Source/Common/Preferences.cpp index fe4578b34..20e8a78f6 100644 --- a/Source/Common/Preferences.cpp +++ b/Source/Common/Preferences.cpp @@ -867,10 +867,10 @@ int Preferences::ExplorerShell() } } } - ExplorerShell_Edit("SystemFileAssociations\\audio", 0, IsChanged); - ExplorerShell_Edit("SystemFileAssociations\\Directory.Audio", 0, IsChanged); - ExplorerShell_Edit("SystemFileAssociations\\Directory.Video", 0, IsChanged); - ExplorerShell_Edit("SystemFileAssociations\\video", 0, IsChanged); + ExplorerShell_Edit("Software\\Classes\\SystemFileAssociations\\audio", 0, IsChanged); + ExplorerShell_Edit("Software\\Classes\\SystemFileAssociations\\Directory.Audio", 0, IsChanged); + ExplorerShell_Edit("Software\\Classes\\SystemFileAssociations\\Directory.Video", 0, IsChanged); + ExplorerShell_Edit("Software\\Classes\\SystemFileAssociations\\video", 0, IsChanged); //Adding/removing to SystemFileAssociations int32s ShellExtension=Config.Read(__T("ShellExtension")).To_int32s(); diff --git a/Source/Install/MediaInfo_Extensions.nsh b/Source/Install/MediaInfo_Extensions.nsh index 1075b4a51..aa8758eb2 100644 --- a/Source/Install/MediaInfo_Extensions.nsh +++ b/Source/Install/MediaInfo_Extensions.nsh @@ -1,3 +1,10 @@ +!ifndef SHCNE_ASSOCCHANGED + !define SHCNE_ASSOCCHANGED 0x08000000 +!endif +!ifndef SHCNF_IDLIST + !define SHCNF_IDLIST 0x0000 +!endif + !macro MediaInfo_Extensions_Install_I Extension ; Old InfoTip DeleteRegKey HKCR "${Extension}\shellex\{00021500-0000-0000-C000-000000000046}" @@ -37,10 +44,13 @@ ; Removing unwanted entries !insertmacro MediaInfo_Extensions_Uninstall_I "Directory.Audio" !insertmacro MediaInfo_Extensions_Uninstall_I "Directory.Video" + !insertmacro MediaInfo_Extensions_Uninstall_I "audio" + !insertmacro MediaInfo_Extensions_Uninstall_I "Folder" + !insertmacro MediaInfo_Extensions_Uninstall_I "video" ; directories WriteRegStr HKCU "Software\Classes\Directory\Shell\MediaInfo" "Icon" "$INSTDIR\MediaInfo.exe" - WriteRegStr HKCU "Software\Classes\Directory\\Shell\MediaInfo\Command" "" "$\"$INSTDIR\MediaInfo.exe$\" $\"%1$\"" + WriteRegStr HKCU "Software\Classes\Directory\Shell\MediaInfo\Command" "" "$\"$INSTDIR\MediaInfo.exe$\" $\"%1$\"" ; Per item !insertmacro MediaInfo_Extensions_Install_I ".264" @@ -198,9 +208,8 @@ !insertmacro MediaInfo_Extensions_Install_I ".wvc" !insertmacro MediaInfo_Extensions_Install_I ".y4m" - !insertmacro MediaInfo_Extensions_Install_I "audio" - !insertmacro MediaInfo_Extensions_Install_I "Folder" - !insertmacro MediaInfo_Extensions_Install_I "video" + ; Notify Windows Shell to refresh + System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' !macroend !macro MediaInfo_Extensions_Uninstall @@ -371,7 +380,6 @@ !insertmacro MediaInfo_Extensions_Uninstall_I ".wvc" !insertmacro MediaInfo_Extensions_Uninstall_I ".y4m" - !insertmacro MediaInfo_Extensions_Uninstall_I "audio" - !insertmacro MediaInfo_Extensions_Uninstall_I "Folder" - !insertmacro MediaInfo_Extensions_Uninstall_I "video" + ; Notify Windows Shell to refresh + System::Call 'Shell32::SHChangeNotify(i ${SHCNE_ASSOCCHANGED}, i ${SHCNF_IDLIST}, i 0, i 0)' !macroend