Reputation: 229
In my application I create files with extension .mprj.
How can I assign an icon to this type of file?
Does appropriate .Net methods exist?
Upvotes: 4
Views: 330
Reputation: 714
I advise you to use InnoSetup to do that. You can assocaite a program with an extension to add icons, and to launch program when an users click on a file with this extension. (for example to open the file directly in the program like msoffice programs). When we click on an Excel file, Excel is launching and open this file. You can do the samething easy with InnoSetup and little code in main method to parse arguments.
With Innosetup you just add iIn the section [Setup]
ChangesAssociations=yes
And in the section [Registry]
Root: HKCR; Subkey: ".mpl"; ValueType: string; ValueName: ""; ValueData: "{#MyAppName}"; Flags: uninsdeletevalue
Root: HKCR; Subkey: "{#MyAppName}"; ValueType: string; ValueName: ""; ValueData: "Program {#MyAppName}"; Flags: uninsdeletekey
Root: HKCR; Subkey: "{#AppName}\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\{#MyAppExeName},0"
Root: HKCR; Subkey: "{#AppName}\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\{#MyAppExeName}.EXE"" ""%1"""
More information in this previous message
Upvotes: 1
Reputation: 1082
you need to modify registry entries. A code snippet how to do with c# can be found here: http://mel-green.com/2009/04/c-set-file-type-association/
Upvotes: 3