> -----Original Message-----
> From: BeginThread.com MSVC List [mailto:[EMAIL PROTECTED]]On Behalf
> Of Anders W�hlin (GIS)
> Sent: 03 April 2003 07:27
> To: [EMAIL PROTECTED]
> Subject: [MSVC] How to get icon from an extension
>
>
> Hi!
>
> How can I get the icon for a specific extension? For example
> ".doc". I don't have the file name, so I can't use
> SHGetFileInfo(...). I could create a dummy file with the
> extension and then call SHGetFileInfo, but there has to be another way?
You can obtain the path and name of the EXE file that relates to the
extension from the registry.
If the application uses the .DPQ extension, then look at
HKEY_CLASSES_ROOT\.DPQ
(yes, the period should be there). The default value for this key is the
document type, say "dpqfile". Now go and look at
HKEY_CLASSES_ROOT\dpqfile
Undert his should be
shell\open\command
The default value for THIS subkey is the path and name of the EXE.
Now, under the dpqfile key there is also a
DefaultIcon
subkey. The default value for this key names the filename only, with a comma
and number immediately after it. This indicates the index into the list of
icon resources within that file that leads to the current icon.
Thus, by using a combination of these two, you can find the right icon to
extract.
Whether this is easier than the way you suggested, who knows? {:v)
--
Jason Teagle
[EMAIL PROTECTED]
