Click to See Complete Forum and Search --> : HOW TO associate un icon to an extension ?


May 3rd, 1999, 04:06 AM
Hi,

In my project, the user can save files with different extensions, which are specific to my project : for example .ext1, .ext2, .ext3.

Now, I would like to associate an icon to these extensions. I put icons in my ressources, but I don't know how to associate each of them with one of my files.

The result will be that, when the user goes in the Windows Explorer, he sees the files with these extensions with specifics icons.

Thanks for your help.

Best Regards

Stéph.

Troy T
May 3rd, 1999, 05:35 PM
It sounds like rather than actually associating an icon to your extension, you need to register a file type in Windows. That way, you specify an icon for your file type, and it will do that for you automatically. If you are using a SDI or MDI based project, chances are that you already have a file type created for your project, and you will just have to modify the icon listed as IDR_MAINFRAME to get this to happen. Otherwise, if your app is dialog based, you will have to explicitly register a file type with Windows. Here is an excerpt from MSDN that may be of some guidance. Just lookup (or search) for "File Types" or "Registering File Types" and you will find some information..

Registering a File Extension Type
Windows CE Explorer, like Windows Explorer, allows you to customize a type name, as displayed in the details view of Explorer, and an icon for any file extension, for example, .pwd. File filters must be registered under HKEY_CLASSES_ROOT.

The following is the structure of HKEY_CLASSES_ROOT:

HKEY_CLASSES_ROOT\.<file extension>
\(Default) = <Class Name>
HKEY_CLASSES_ROOT\<Class Name>
\(Default) = <Name to be displayed in the "Type" column of Explorer>
\DefaultIcon = <filename or index of the icon for this type>

Good luck!

- Troy