7

Is it possible to extract the associated icon from a file extension?

I have found many examples, but they all need a reference to a file (path). I want to be able to only pass the extension like "pdf" or ".pdf" and then get the associated icon from it (small, medium, large, extralarge and jumbo).

Additional information

I have some data in a database which holds information about a file. The filename and the extension are the ones I need for this problem.

In my UI I want to be able to show a listview of all the files that are in my database. I want to show this with the filename + icon of the file type.

In my UI I also have a scaler so I can make the icons grow bigger or smaller like you see in Windows Explorer (Medium icons, Large Icons, etc.). In order to do this I would like to get the associated icon which my OS uses to show the file in Windows Explorer. This icon I can use in my listview.

I have found solutions where I can get the associated icon, but they all need to have the filepath to extract the icon from. For example: using SHFILEINFO to get file icons

What I want is to be able to pass the extension instead of a filepath.

Community
  • 1
  • 1
Kaizer
  • 651
  • 3
  • 9
  • 22
  • 1
    Are you talking about registered mime types within OS? If that's the case, registry will be your friend and its subtree of CLASSIDs. Actually this is a very **original and interesting question**. Please edit your question and update with additional details. What exactly you're after, so you'll be more likely to keep this question open. – Robert Koritnik Feb 11 '15 at 12:32
  • I think you mean you want to get the association application from the registry and then the icon that is shown in Windows Explorer for that association? – Yuck Feb 11 '15 at 12:33
  • 2
    I'm voting to close this question as off-topic because this question makes no attempt to solve the problem or describe the specifics of the problem. Please make an attempt to solve the problem and ask a question about your specific issues. – Ian Feb 11 '15 at 12:33
  • 4
    @Ian: That's somehow unfair. You can't assume one's level of experience just by the question they ask. Maybe OP doesn't have a slightest clue where to start... Especially close-voting for it as not being about programming? WTF? – Robert Koritnik Feb 11 '15 at 12:34
  • 1
    @RobertKoritnik The problem is that this question is really (1) how do I find the associated application for a file type in the registry (2) how do I find the icon for that application and (3) how do I find different sizes for that icon. None of these were attempted and they each deserve their own questions. As it is now, there is no way to answer this question up to SO's standards. – Yuck Feb 11 '15 at 12:37
  • 4
    @RobertKoritnik: A quick search though in Google reveals this http://stackoverflow.com/questions/2701263/get-the-icon-for-a-given-extension which then follows through to a quite detailed code project article. This is just the 1st Google result – Ian Feb 11 '15 at 12:37
  • Fair enough @Ian. In that case, this question should be closed as a duplicate. but it's not exactly. First part is therefore already answered by the linked SO question. Now the sizes still remain open. – Robert Koritnik Feb 11 '15 at 12:39
  • @RobertKoritnik: True it should, but I only found that afterwards. I'd change my close vote if I could. – Ian Feb 11 '15 at 12:39

0 Answers0