Hi,
There are several approaches to fetch the description and default icon for a given extension (no full path), e.g for "*.doc" I want to get "Microsoft Word Document" and the related icon, which do you think will be the fastest one of the following:
Search the registry:
- in registry, go to "HKCR.{extension}", read the default value (let's call it filetype)
- in "HKCR{filetype}\DefaultIcon", read the default value: this is the path to the icon file (or icon container file, like an .exe with an embedded icon resource)
- if needed, use your preferred method of extracting the icon resource out of the mentioned file.
Call API ShGetFileInfo. I believe this is a bit slow.
According to Rob, here: http://stackoverflow.com/questions/829843/how-to-get-icon-and-description-from-file-extension-using-delphi
Calls the IExtractIcon interface a "more flexible and efficient" alternative. But the sequence it recommends is to use an IShellFolder interface, then call GetUIObjectOf to get the file's IExtractIcon interface, and then call GetIconLocation and Extract on it to retrieve the icon's handle. (but this method cannot read the extension description?)
Since the speed is very important because I need to read the info for all the file types in the system.
Thank you very much!