File type icons
-
Is there an API function to retrieve the icon of a particular document, or do I have to acquire it myself by scanning the registry? -- This space for rent.
-
Is there an API function to retrieve the icon of a particular document, or do I have to acquire it myself by scanning the registry? -- This space for rent.
I've looked for this in several projects I've done, and have always resorted to the registry. :-( A simple class for this would be useful to have on hand. Regardz Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining. Said by Roger Wright about me.
-
I've looked for this in several projects I've done, and have always resorted to the registry. :-( A simple class for this would be useful to have on hand. Regardz Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining. Said by Roger Wright about me.
Colin Davies wrote: A simple class for this would be useful to have on hand. I'll submit an article about such a class, if I figure out a nice way to do it. Wish me luck! :) -- This space for rent.
-
I've looked for this in several projects I've done, and have always resorted to the registry. :-( A simple class for this would be useful to have on hand. Regardz Colin J Davies
Sonork ID 100.9197:Colin
You are the intrepid one, always willing to leap into the fray! A serious character flaw, I might add, but entertaining. Said by Roger Wright about me.
The class will be finished by dawn, sir. ;) -- This space for rent.
-
The class will be finished by dawn, sir. ;) -- This space for rent.
-
Is there an API function to retrieve the icon of a particular document, or do I have to acquire it myself by scanning the registry? -- This space for rent.
Try using
ShGetFileInfo
. It works for all Win32 versions of Windows.
Software Zen:
delete this;
-
Is there an API function to retrieve the icon of a particular document, or do I have to acquire it myself by scanning the registry? -- This space for rent.
I do it with
SHGetFileInfo()
, however AFAIK it doesn't restrieve the 48x48 icon, only 16x16 and 32x32. Here's how to get the icon for DLL files:SHFILEINFO sfi = {0};
SHGetFileInfo ( _T("foo.dll"), FILE_ATTRIBUTE_NORMAL,
&sfi, sizeof(SHFILEINFO),
SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |
SHGFI_LARGEICON );// now sfi.hIcon holds the 32x32 icon
Replace
SHGFI_LARGEICON
withSHFGI_SMALLICON
to get the 16x16 one. Note that foo.dll doesn't need to exist, theSHGFI_USEFILEATTRIBUTES
flag tells the API to just look at the extension of the name you pass. --Mike-- Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23 :( 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_Helm -
I do it with
SHGetFileInfo()
, however AFAIK it doesn't restrieve the 48x48 icon, only 16x16 and 32x32. Here's how to get the icon for DLL files:SHFILEINFO sfi = {0};
SHGetFileInfo ( _T("foo.dll"), FILE_ATTRIBUTE_NORMAL,
&sfi, sizeof(SHFILEINFO),
SHGFI_USEFILEATTRIBUTES | SHGFI_ICON |
SHGFI_LARGEICON );// now sfi.hIcon holds the 32x32 icon
Replace
SHGFI_LARGEICON
withSHFGI_SMALLICON
to get the 16x16 one. Note that foo.dll doesn't need to exist, theSHGFI_USEFILEATTRIBUTES
flag tells the API to just look at the extension of the name you pass. --Mike-- Friday's GoogleFight results: Britney Spears 2,190,000 - Erica Weichers 23 :( 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click! My really out-of-date homepage Sonork-100.19012 Acid_HelmArgh... I just wrote an article on how to grab the data from the registry. Thanks for the info though! -- This space for rent.
-
Try using
ShGetFileInfo
. It works for all Win32 versions of Windows.
Software Zen:
delete this;
Argh... I just wrote an article on how to grab the data from the registry. Thanks for the info though! -- This space for rent.
-
Argh... I just wrote an article on how to grab the data from the registry. Thanks for the info though! -- This space for rent.
Hey - Submit the article anyway. I'd like to read it. Any information on how Windows uses the registry is useful!
Software Zen:
delete this;
-
Hey - Submit the article anyway. I'd like to read it. Any information on how Windows uses the registry is useful!
Software Zen:
delete this;
Doh! I deleted it. :) I didn't want to use CP as a storage when there's already an API function for it! Here's however a simple rundown of the implementation if you're interested:
- For a file extension "doc", open HKEY_CLASSES_ROOT\.doc Look at the default value. It's a part key name, for instance Word.Document.8. Also, HKEY_CLASSES_ROOT\.doc may contain information such as content type (mime) worth collecting
- Assuming the key name was Word.Document.8, open HKEY_CLASSES_ROOT\Word.Document.8
- Collect the data you want from here (default icon, file type descriptions, etc.)
I have the code lying around still if you want it. -- Only in a world this shitty could you even try to say these were innocent people and keep a straight face.