Get the associated program name and icon for a file extension in windows api

What is the best way to get the name and icon of the associated program for a file with windows api (Win32).

  • By reading the information from the Windows registry. First by looking up the file extension to get the DocType, and then by looking up the DocType to find its associated application. The icon is usually not included there, because it’;s usually the default (first) icon in the application, which is obtained directly from that application’s resources that have been linked into it. Have you done any research (such as searching using your favorite search engine) to see if this has been asked about before?

    – 




  • Does this answer your question? How can I get the Name of the Program associated with a file extension using Delphi?

    – 

  • The “best way” is pretty hard to define without a specific use case. What are your intentions? In what datatype / format do you want the icon? Should the solution work with edge cases like .bat files?

    – 




  • Here are the edge cases I’d like to know: Files that are executed by the shell like .bat, .cmd. Would you like the name of cmd.exe to show up? If I just have “myexe.exe” should the name and icon of the exe be used, or is this not a valid associated file? What happens with symlinks?

    – 




Leave a Comment