Click here to Skip to main content
15,891,033 members
Articles / Desktop Programming / MFC
Article

Getting Icons of Remote Files

Rate me:
Please Sign up or sign in to vote.
3.15/5 (7 votes)
21 Nov 2005CPOL 46.5K   460   15   12
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)


Written By
Software Developer
Germany Germany
I am living in germany and now living from programming for some Years. In my spare time I like sports as jogging, playing football (soccer) and basketball.

We must take care for our planet, because we and our family has no other. And everybody has to do something for it.

Comments and Discussions

 
GeneralMy vote of 1 Pin
dxlee6-Oct-09 3:49
dxlee6-Oct-09 3:49 
GeneralMy vote of 2 Pin
accesstomypc10-Sep-09 5:02
accesstomypc10-Sep-09 5:02 
GeneralIt's a pretty nice solution Pin
deepkh17-Apr-08 16:33
deepkh17-Apr-08 16:33 
QuestionRemote files? Pin
Hans Dietrich23-Nov-05 5:42
mentorHans Dietrich23-Nov-05 5:42 
AnswerRe: Remote files? Pin
KarstenK23-Nov-05 20:42
mveKarstenK23-Nov-05 20:42 
GeneralRe: Remote files? Pin
Hans Dietrich23-Nov-05 21:55
mentorHans Dietrich23-Nov-05 21:55 
GeneralRe: Remote files? Pin
KarstenK23-Nov-05 22:04
mveKarstenK23-Nov-05 22:04 
QuestionSHGetFileInfo? Pin
Justin Tay23-Nov-05 2:28
Justin Tay23-Nov-05 2:28 
AnswerRe: SHGetFileInfo? Pin
KarstenK24-Nov-05 1:31
mveKarstenK24-Nov-05 1:31 
Generalbroken links Pin
toxcct22-Nov-05 5:33
toxcct22-Nov-05 5:33 
GeneralRe: broken links Pin
KarstenK22-Nov-05 20:31
mveKarstenK22-Nov-05 20:31 
GeneralRe: broken links Pin
toxcct22-Nov-05 23:04
toxcct22-Nov-05 23:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.