C #: icon associated with file extension

In my application, I create files with the extension .mprj.

How to assign an icon to this file type?

Are there any suitable .Net methods?

+4
source share
2 answers

you need to change registry entries. A code snippet on how to do with C # can be found here: http://mel-green.com/2009/04/c-set-file-type-association/

+3
source

I advise you to use InnoSetup for this. You can associate a program with an extension to add icons and run the program when users click on a file with this extension. (for example, to open a file directly in a program, for example, msoffice program). When we click on the Excel file, Excel launches and opens this file. You can do simple with InnoSetup and a little code in the main method for parsing arguments.

With Innosetup, you simply add the iIn [Setup] section

ChangesAssociations=yes 

And in the [Registry] section

 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""" 

Further information in this previous post.

+1
source

Source: https://habr.com/ru/post/1381660/


All Articles