How can I get the Name of the Program associated with a file extension using Delphi?

Posted by lkessler on Stack Overflow See other posts from Stack Overflow or by lkessler
Published on 2010-04-05T06:36:50Z Indexed on 2010/04/05 6:43 UTC
Read the original article Hit count: 380

I need to get the name of the program currently associated with a file extension for the current user. If you right-click on a file and select properties, then what I need is the program name that is to the right of the "Opens with" line.

e.g. For ".xls", I want to be able to get the answer "Microsoft Office Excel", or whatever program the user has as their default program to open .xls files.

I have determined it's not as easy as just going into HKEY_CLASSES_ROOT and picking it out, since it may also be specified in HKEY_LOCAL_MACHINE or HKEY_CURRENT_USER or HKEY_USERS.

Maybe all I need to know is the pecking order used by Windows to determine this and how to get to each of the locations. Of course, a Windows API call to do this would be ideal.

This is a similar question to: How to get icon and description from file extension using Delphi? but that question only answered how to get the description of the extension and the icon of the associated program. I couldn't find a way to extend that to also get the name of the associated program.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about file-association