Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / desktop / MFC

Getting Icons of Remote Files

3.15/5 (7 votes)
22 Nov 2005CPOL 1   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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)