Inno Setup: Extending Windows default apps list

2019-02-19 04:08发布

问题:

How is it possible to have listed my application on the Windows default apps list?

I have a special Java based video player application with an installer created by Inno Setup. I want my application to be listed on the selectable video players list on Windows 10 (I also don't know how to do it with older Windows versions).

回答1:

For generic information, see:

  • Registering an Application for Use with Default Programs on MSDN.
  • How do I add my application in the Default Programs list of Windows Vista/7? on Stack Overflow

In Inno Setup, you implement this using [Registry] section:

[Registry]
; Create the application capability key
Root: HKLM; Subkey: "Software\My Company"; Flags: uninsdeletekeyifempty
Root: HKLM; Subkey: "Software\My Company\My Program"; Flags: uninsdeletekeyifempty
Root: HKLM; Subkey: "Software\My Company\My Program\Capability"; \
    ValueType: string; ValueName: "ApplicationDescription"; \
    ValueData: "This is My Program that does stuff"; Flags: uninsdeletevalue
Root: HKLM; Subkey: "Software\My Company\My Program\Capability"; \
    ValueType: string; ValueName: "ApplicationName"; ValueData: "My Program"; \
    Flags: uninsdeletevalue
; List of extensions the application supports
Root: HKLM; Subkey: "Software\My Company\My Program\Capability\FileAssociations"; \
    ValueType: string; ValueName: ".jpg"; ValueData: "MyProgram.JPEG"; \
    Flags: uninsdeletevalue

; Add the capability key to list of registered applications
Root: HKLM; Subkey: "Software\RegisteredApplications"; \
    ValueType: string; ValueName: "My Program"; \
    ValueData: "Software\My Company\My Program\Capability"; \
    Flags: uninsdeletevalue

; For each extension that the application supports
Root: HKCR; Subkey: "MyProgram.JPEG"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "MyProgram.JPEG"; \
    ValueType: string; ValueName: ""; ValueData: "MyProgram JPEG"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "MyProgram.JPEG\DefaultIcon"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "MyProgram.JPEG\DefaultIcon"; \
    ValueType: string; ValueName: ""; ValueData: "{app}\MyProg.exe,1"; \
    Flags: uninsdeletevalue
Root: HKCR; Subkey: "MyProgram.JPEG\Shell"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "MyProgram.JPEG\Shell\open"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "MyProgram.JPEG\Shell\open\Command"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "MyProgram.JPEG\Shell\open\Command"; \
    ValueType: string; ValueName: ""; ValueData: """{app}\MyProg.exe"" ""%1"""; \
    Flags: uninsdeletevalue