locked
IconHandler Shell Extension is being overridden by default program RRS feed

  • Question

  • I created an IconHandler shell extension for my program. It handles icons for .plan files.  

    This works fine if .plan is not registered with a default program. But once it is, the icon is overridden with the icon for the executable.

    I can delete the UserChoice key in  Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.plan

    , but then my extension is no longer associated.

    Basically I want to associate an extension with a program AND use my IconHandler for custom icons.

    What can I do?

    Monday, January 22, 2018 9:18 PM

Answers

  • icon handler is part of the file association. DefaultIcon must be %1 for your handler to work, when it gets overwritten by another program to "exefilename, resourceid", your icon handler will stop working. 

    UserChoice is created to prevent you from taking the file association back programmatically. The file association is the user's choice, not yours. Best you can do is to register your file association then hope the user would choose you over the other program. 



    Visual C++ MVP

    • Marked as answer by Acrym Wednesday, February 7, 2018 1:32 AM
    Monday, January 22, 2018 10:32 PM

All replies

  • First, you should read and study https://www.codeproject.com/Articles/797/The-Complete-Idiots-Guide-to-Writing-Shell-Exten.

    Then download the sample code and build the Icon Handler for the txtfile file type.  On my system where notepad.exe was registered as the default program for text files the demo Icon Handler still provided the icons displayed by explorer.  The sample code is quite old so you may need to tweak it a little bit to get it to build with modern versions of Visual Studio and ATL.

    • Proposed as answer by Hart Wang Thursday, January 25, 2018 9:38 AM
    Monday, January 22, 2018 10:11 PM
  • icon handler is part of the file association. DefaultIcon must be %1 for your handler to work, when it gets overwritten by another program to "exefilename, resourceid", your icon handler will stop working. 

    UserChoice is created to prevent you from taking the file association back programmatically. The file association is the user's choice, not yours. Best you can do is to register your file association then hope the user would choose you over the other program. 



    Visual C++ MVP

    • Marked as answer by Acrym Wednesday, February 7, 2018 1:32 AM
    Monday, January 22, 2018 10:32 PM
  • icon handler is part of the file association. DefaultIcon must be %1 for your handler to work, when it gets overwritten by another program to "exefilename, resourceid", your icon handler will stop working. 

    Sounds like the likely culprit.  In my quick and dirty test the default program was selected before the icon handler was registered.
    Monday, January 22, 2018 10:34 PM