Click to See Complete Forum and Search --> : How To Set Icon To File


prakashjoshi0101
May 9th, 2007, 08:00 AM
Hi All,

I would like to set Icon to a file created by CFile (MFC).

We can attached Icon to file manullay through
TOOLS-->FOLDER OPTIONS-> FILE TYPES
Select your file type and you can change its icon or program connected to it.

But I would like to set Icon programmatically.

Thanks
-Prakash Joshi.

PeejAvery
May 9th, 2007, 08:09 AM
You can change do this by editing the registry.

HKEY_CLASSES_ROOT\_EXTENSION_\DefaultIcon

prakashjoshi0101
May 9th, 2007, 09:23 AM
Hi El Chinchito,

I am really sorry about that i am not able to find
HKEY_CLASSES_ROOT\_EXTENSION_\DefaultIcon key.

Please suggest me a way.

I do have a question this key must be containing path of ".ico" file as value?
If we find this key then we have to change that path of .ico file to our .ico file one right?

Thanks & Regards,
-Prakash Joshi.

PeejAvery
May 9th, 2007, 10:52 AM
Under the HKEY_CLASSES_ROOT are listed all the extensions or title names of file types. Find the DefaultIcon key and alter it, or create one.

prakashjoshi0101
May 17th, 2007, 04:29 AM
Thanks for Reply.

I have set a Icon with the help help of your reply.

i have created "DefaultIcon" Key under my file extension i.e. *.bpt and assigned value i.e. path of .ico file.

it is working fine, but now this is a hardcoded path and i have to supply .ico file separately.

it would be great if I can attach an ICON in dll resources and use the same.

please suggest how this "DefaultIcon" key can point to ICON resource from dll.


i have seen some other file's "DefaultIcon" which have value something like

"C:\PROGRA~1\COMMON~1\MICROS~1\OFFICE11\MSOICONS.EXE,6"

what does this 6 mean?


Thanks!
Prakash Joshi

PeejAvery
May 17th, 2007, 08:24 AM
Icon resources can have multiple icons. You may see them by using icon library browsers. The number is at what place the icon is found. For example: 6 = 6th icon in the library.

.pcbrainbuster
June 19th, 2007, 06:27 PM
A better example is this -
right click n any file and click customise then go to that button at the bttom which lets you choose one, then input/browse to the directory of the dll and you will see 1 or multiple icons and this is where the number comes into hand, just so Windows does not get confused on what image you want to use for your extension there is a numbering system for the icons that is set like this -

0 4 8
1 5 9
2 6
3 7

Say the dll had 10 icons, if you wanted the second icon you would type the full directory to the file then put a comma and then the number for your icon. I guess I should explain how the number system works: Well the number starts as zero and goes up column wise and continues at the next column as stated in the image above...

I'm very sure I explained it stupidly but I am not good at explaining so this is all I could giv you...

P.S. They are called index numbers and not numbers...

PeejAvery
June 19th, 2007, 07:08 PM
P.S. They are called index numbers and not numbers...
No one ever said they were called "numbers."