Skip to content

Commit

Permalink
Don't set unnecessary SupportedTypes key on file associations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanrussell authored Dec 31, 2024
1 parent 03b5a4c commit 4b05dce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
1 change: 0 additions & 1 deletion Examples/Example3.iss
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ Root: HKA; Subkey: "Software\Classes\.myp\OpenWithProgids"; ValueType: string; V
Root: HKA; Subkey: "Software\Classes\MyProgramFile.myp"; ValueType: string; ValueName: ""; ValueData: "My Program File"; Flags: uninsdeletekey
Root: HKA; Subkey: "Software\Classes\MyProgramFile.myp\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MyProg.exe,0"
Root: HKA; Subkey: "Software\Classes\MyProgramFile.myp\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\MyProg.exe"" ""%1"""
Root: HKA; Subkey: "Software\Classes\Applications\MyProg.exe\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""
; HKA (and HKCU) should only be used for settings which are compatible with
; roaming profiles so settings like paths should be written to HKLM, which
; is only possible in administrative install mode.
Expand Down
12 changes: 8 additions & 4 deletions Projects/Src/IDE.FileAssocFunc.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

{
Inno Setup
Copyright (C) 1997-2020 Jordan Russell
Copyright (C) 1997-2024 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Expand Down Expand Up @@ -83,8 +83,6 @@ function RegisterISSFileAssociation(const AllowInteractive: Boolean; var AllUser
SetKeyValue(Rootkey, 'Software\Classes\InnoSetupScriptFile\shell\Compile\command', nil,
'"' + SelfName + '" /cc "%1"');

SetKeyValue(Rootkey, PChar('Software\Classes\Applications\' + PathExtractName(SelfName) + '\SupportedTypes'), '.iss', '');

{ If we just associated for all users, remove our existing association for the current user if it exists. }
if AllUsers then
UnregisterISSFileAssociationDo(HKEY_CURRENT_USER, False);
Expand Down Expand Up @@ -144,7 +142,9 @@ procedure UnregisterISSFileAssociationDo(const Rootkey: HKEY; const ChangeNotify
SelfName: String;
NumSubkeys, NumValues: DWORD;
begin
if not KeyExists(Rootkey, 'Software\Classes\InnoSetupScriptFile') and not KeyExists(Rootkey, 'Software\Classes\.iss') then
if not KeyExists(Rootkey, 'Software\Classes\InnoSetupScriptFile') and
not KeyExists(Rootkey, 'Software\Classes\.iss') and
not KeyExists(Rootkey, 'Software\Classes\Applications\Compil32.exe') then
Exit;

SelfName := NewParamStr(0);
Expand Down Expand Up @@ -176,6 +176,10 @@ procedure UnregisterISSFileAssociationDo(const Rootkey: HKEY; const ChangeNotify
end;
RegDeleteKeyIfEmpty(rvDefault, RootKey, 'Software\Classes\.iss');

{ Remove unnecessary key set by previous versions }
RegDeleteKeyIncludingSubkeys(rvDefault, Rootkey,
'Software\Classes\Applications\Compil32.exe');

if ChangeNotify then
SHChangeNotify(SHCNE_ASSOCCHANGED, SHCNF_IDLIST, nil, nil);
end;
Expand Down
1 change: 0 additions & 1 deletion Projects/Src/IDE.Wizard.WizardForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,6 @@ procedure TWizardForm.GenerateScript;
Registry := Registry + 'Root: HKA; Subkey: "Software\Classes\' + AppAssocKey + '"; ValueType: string; ValueName: ""; ValueData: "' + AppAssocNameEdit.Text + '"; Flags: uninsdeletekey' + SNewLine;
Registry := Registry + 'Root: HKA; Subkey: "Software\Classes\' + AppAssocKey + '\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\' + AppExeName + ',0"' + SNewLine;
Registry := Registry + 'Root: HKA; Subkey: "Software\Classes\' + AppAssocKey + '\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\' + AppExeName + '"" ""%1"""' + SNewLine;
Registry := Registry + 'Root: HKA; Subkey: "Software\Classes\Applications\' + AppExeName + '\SupportedTypes"; ValueType: string; ValueName: ".myp"; ValueData: ""' + SNewLine;
end;

FFilesHelper.AddScript(Files);
Expand Down

0 comments on commit 4b05dce

Please sign in to comment.