This is probably a basic question, but I don't understand registry well enough. My application uses 2 kinds of files : .bmc and .mef. I want them to be displayed with 2 different icons. I did:
Root: HKCR; Subkey: ".bmc"; ValueType: string; ValueName: ""; ValueData: "MyProg"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "MyProg"; ValueType: string; ValueName: ""; ValueData: "MyProg File"; Flags: uninsdeletekey
Root: HKCR; Subkey: "MyProg\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MyProg.exe,0"
Root: HKCR; Subkey: "MyProg\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\MyProg.exe"" ""%1"""
This successfully links my program to one fileType and displays the files with the right icon.
Now, how can I link the second fileType with the same program, but displaying another icon ?
Thanks a lot for your help !
According to this article
you can create a DefaultIcon
subkey for your extension. There is an example showing how to explicitly assign an icon to the extension:
The following example shows a detailed view of the registry entries that are required for a file-type icon assignment. The file name extension is associated with an application, but the icon assignment is to the file name extension itself so that the associated application does not dictate the default icon.
HKEY_CLASSES_ROOT .myp (Default) = MyProgram.1 DefaultIcon (Default) = C:\MyDir\MyProgram.exe,2
So I think your script can be modified this way:
; register application
Root: HKCR; Subkey: "MyProg"; ValueType: string; ValueName: ""; ValueData: "MyProg File"; Flags: uninsdeletekey
Root: HKCR; Subkey: "MyProg\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MyProg.exe,0"
Root: HKCR; Subkey: "MyProg\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\MyProg.exe"" ""%1"""
; register .bmc extension and let it inherit the assigned app's DefaultIcon icon
Root: HKCR; Subkey: ".bmc"; ValueType: string; ValueName: ""; ValueData: "MyProg"; Flags: uninsdeletevalue
; register .mef extension and explicitly specify its icon (icon index 1 of your app.)
Root: HKCR; Subkey: ".mef"; ValueType: string; ValueName: ""; ValueData: "MyProg"; Flags: uninsdeletevalue
Root: HKCR; Subkey: ".mef\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\MyProg.exe,1"; Flags: uninsdeletevalue