9

I know how to change an icon for a whole file type using registry and file type association. I also know how to change an icon for a separate folder using desktop.ini file.

My questions is whether it is possible to change an icon for one specific file, let's say one.doc file?

I cannot find a way doing it, yet some upload programs seem to be able to change an icon of the currently uploaded file, while all other files of this type stay with the standard icon. How do they do it?

I can accept a solution in any language; VB, C++, C# - anything goes, though C# is preferable. Thanks

11
  • You just want to change it from the default icon on one document?
    – Charlie
    Jan 28, 2012 at 16:38
  • Are you on a mac or windows? I assume windows...
    – Charlie
    Jan 28, 2012 at 16:42
  • 1
    I feel like I don't understand the question entirely... you want to do it in C# but why not just change it from windows? vlaurie.com/computers2/Articles/icons.htm
    – Charlie
    Jan 28, 2012 at 16:49
  • @Charlie - because if you change an icon from Windows, it will change it for the whole type, while I want to do it for one specific file of that type, let's say one Word document. Creating a shortcut isn't a solution, as I want to change the icon of the original file.
    – Flot2011
    Jan 28, 2012 at 16:55
  • You probably misinterpret what an "upload program" does. They commonly use a different filename extension while the upload takes place. Renaming it when it completes. The icon automatically changes as a side-effect. Jan 28, 2012 at 17:29

3 Answers 3

6

You can use an IconHandler to allow icons to be customized on a file-by-file basis. Note that shell extensions should not be written in managed code, so C++ is the language of choice here.

Note also that it's highly unusual to be installing an icon handler for another application's file type.

2
  • actually I was looking for a way to change an original icon, something that Tortoise does, for example. I have already figured out that Icon Overlay Handler should be used for this, however your post turned me in another direction. One can have only up to 14 Icon Overlay Handlers simultaneously, while a number of Icon Handlers seems to be unlimited, so probably it is a better course to take. Thank you.
    – Flot2011
    Jan 30, 2012 at 14:23
  • 2
    However, there can be only one Icon Handler per file type, so installing an Icon Handler should really be done only by the owner of the file type. Otherwise you have the "What if two people did this?" problem. Jan 30, 2012 at 17:31
3

I realize that this thread is pretty old. But for users who have less experience in coding, a good alternative is the following.

  1. Put your target file somewhere.
  2. Create a shortcut item to that file.
  3. Now you can change the icon of the shortcut using its property window.

Just another solution. More of a workaround really.

1
  • The issue with what you say is how do you do that programmatically, because a link created with mklink for instance won't be customizable like a link created with a right click. Aug 31, 2020 at 22:37
-1

If you create a SHORTCUT file to that file, then simply RIGHT click on that SHORTCUT, you get the options to change the ICON.

1
  • This is the same suggestion that @Lost-in-Knowledge gave a couple of years ago. Feb 14, 2022 at 0:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.