简体   繁体   English

将文件类型/扩展名与 Inno Setup 中 an.exe 文件中的非主图标相关联

[英]Associate file type/extension with a non-primary icon from an .exe file in Inno Setup

I am trying to get Inno Setup to associate three file types with my application and to assign an icon to each which have been embedded in my application.我试图让 Inno Setup 将三种文件类型与我的应用程序相关联,并为每个嵌入在我的应用程序中的文件类型分配一个图标。

I have edited this question now to reflect the Up-To-Date method as suggested.我现在已经编辑了这个问题,以反映建议的最新方法。

I have added two icons to my main application, the Main application icon and Icon_1 and Icon_2 for file types which used by my Delphi application.我在我的主应用程序中添加了两个图标,主应用程序图标和 Icon_1 和 Icon_2 用于我的 Delphi 应用程序使用的文件类型。 I used the Resources and Images Dialog under the Project menu to add them.我使用项目菜单下的资源和图像对话框来添加它们。 The script I have used for this is below.我用于此的脚本如下。

[Registry]
; Create the application capability key
Root: HKLM; Subkey: "Software\{#MyAppPublisher}"; Flags: uninsdeletekeyifempty
Root: HKLM; Subkey: "Software\{#MyAppPublisher}\{#MyAppName}"; Flags: uninsdeletekeyifempty
Root: HKLM; Subkey: "Software\{#MyAppPublisher}\{#MyAppName}\Capability"; ValueType: string; ValueName: "ApplicationDescription"; ValueData: "Integrated Development Environment for Positron Compilers"; Flags: uninsdeletevalue
Root: HKLM; Subkey: "Software\{#MyAppPublisher}\{#MyAppName}\Capability"; ValueType: string; ValueName: "ApplicationName"; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue

; List of extensions the application supports
Root: HKLM; Subkey: "Software\{#MyAppPublisher}\{#MyAppName}\Capability\FileAssociations"; ValueType: string; ValueName: ".bas"; ValueData: "{#MyAppName}.bas"; Flags: uninsdeletevalue
Root: HKLM; Subkey: "Software\{#MyAppPublisher}\{#MyAppName}\Capability\FileAssociations"; ValueType: string; ValueName: ".inc"; ValueData: "{#MyAppName}.inc"; Flags: uninsdeletevalue
Root: HKLM; Subkey: "Software\{#MyAppPublisher}\{#MyAppName}\Capability\FileAssociations"; ValueType: string; ValueName: ".psproj"; ValueData: "{#MyAppName}.psproj"; Flags: uninsdeletevalue

; Add the capability key to list of registered applications
Root: HKLM; Subkey: "Software\RegisteredApplications"; ValueType: string; ValueName: "{#MyAppName}"; ValueData: "Software\#MyAppPublisher}\{#MyAppName}\Capability"; Flags: uninsdeletevalue

; For each extension that the application supports
Root: HKCR; Subkey: "{#MyAppName}.bas"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.bas"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName} bas"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppName}.bas\DefaultIcon"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.bas\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},1"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppName}.bas\Shell"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.bas\Shell\open"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.bas\Shell\open\Command"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.bas\Shell\open\Command"; ValueType: string; ValueName: ""; ValueData: """{app}{#MyAppExeName}"" ""1"""; Flags: uninsdeletevalue

Root: HKCR; Subkey: "{#MyAppName}.inc"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.inc"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName} inc"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppName}.inc\DefaultIcon"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.inc\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},1"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppName}.inc\Shell"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.inc\Shell\open"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.inc\Shell\open\Command"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.inc\Shell\open\Command"; ValueType: string; ValueName: ""; ValueData: """{app}{#MyAppExeName}"" ""1"""; Flags: uninsdeletevalue

Root: HKCR; Subkey: "{#MyAppName}.psproj"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.psproj"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName} psproj"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppName}.psproj\DefaultIcon"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.psproj\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},1"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppName}.psproj\Shell"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.psproj\Shell\open"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.psproj\Shell\open\Command"; Flags: uninsdeletekeyifempty
Root: HKCR; Subkey: "{#MyAppName}.psproj\Shell\open\Command"; ValueType: string; ValueName: ""; ValueData: """{app}{#MyAppExeName}"" ""1"""; Flags: uninsdeletevalue

Now the associations seem to have been lost.现在这些关联似乎已经丢失了。 I know I have two icons in the file because when I create a short cut I can choose from either icon.我知道文件中有两个图标,因为当我创建快捷方式时,我可以从任一图标中进行选择。 What do I need to do to get the correct icon on my files?我需要做什么才能在我的文件上获得正确的图标?

In the registry HKEY_CLASSES_ROOT under .bas I have:.bas下的注册表HKEY_CLASSES_ROOT我有:

DefaultIcon - not set
ProgWithIDs - not set
PersitentHandler - {5e941d80-bf96-11cd-b579-08002b30bfeb}

You have to replace the %1 with the 0-based index of the icon group within the.exe file.您必须将%1替换为 .exe 文件中图标组的从 0 开始的索引。

Root: HKCU; Subkey: "Software\Classes\.bas\DefaultIcon"; ValueName: ""; \
  ValueType: string; ValueData: "{app}\{#MyAppExeName},ICON_GROUP_INDEX_GOES_HERE"; \
  Flags: uninsdeletevalue;

See https://docs.microsoft.com/en-us/windows/win32/shell/how-to-assign-a-custom-icon-to-a-file-type请参阅https://docs.microsoft.com/en-us/windows/win32/shell/how-to-assign-a-custom-icon-to-a-file-type


For example, this will set .isstest icon to Inno Setup's document icon (the second icon in Compil32.exe ):例如,这会将.isstest图标设置为 Inno Setup 的文档图标( Compil32.exe中的第二个图标):

[Registry]
Root: HKCU ; Subkey: "Software\Classes\.isstest"; ValueData: "Icon Test"; \
  ValueType: string; ValueName: ""; Flags: uninsdeletevalue;
Root: HKCU ; Subkey: "Software\Classes\.isstest\DefaultIcon"; ValueType: string; \
  ValueData: "C:\Program Files (x86)\Inno Setup 6\Compil32.exe,1"; ValueName: ""; \
  Flags: uninsdeletevalue;

在此处输入图像描述

在此处输入图像描述


Though this method for file association is obsolete.虽然这种文件关联方法已经过时。 For an up-to-date method, see Inno Setup: Extending Windows default apps list .有关最新方法,请参阅Inno 设置:扩展 Windows 默认应用程序列表 On the other hand, your icon problem is not related to that.另一方面,您的图标问题与此无关。 In the new method, you specify the icon the same way, so you will have the same problem.在新方法中,您以相同的方式指定图标,因此您将遇到相同的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM