Thanks to visit codestin.com
Credit goes to www.codeproject.com

65.9K
CodeProject is changing. Read more.
Home

Getting Icons of Remote Files

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.15/5 (7 votes)

Nov 22, 2005

CPOL
viewsIcon

47180

downloadIcon

461

An easy way to get the icons of remote files if only the extensions are known.

Sample Image - IconDlg.jpg

Introduction

I was working on a Shell Extension COM project which wanted the IExtractIcon to be fed, and because it was over FTP I had a problem fetching icons to get a nice GUI. That's why I looked in CP for a solution but found none. So I developed my own approach to this task and now I think it is an interesting piece of code.

Use of the class

IconExtractor has two important functions:

  • SetExtension( LCPSTR psz);//for which extension to search
  • GetIcon();//get the HICON for drawing

Make sure that you only create new instances if you need them.

Conclusion

The code will get you an Icon from a file extension while looking up in the Registry. Because of the need for special functions to get the icon using the extension, making an array of extensions and a doing lookup of it could/should be interesting.