We help IT Professionals succeed at work.

List all FileTypes with icon

ramses asked
Hi guys and girlies

I'm looking for a way to list all filetypes with icon in a listview control.  What I mean with filetypes is like when you open the Find Files (WIN+F) dialog, select the tab Advanced, en look in the dropdown listbox.  You'll see all registered filetypes on your pc.  Well, I want that functionallity, PLUS the icons that go with it.  

VB Version: VB5CCE

Watch Question

Hai ramses

In order to get the fileType with Icons make use of ImageCombo Control and ImageList

First Add all the Icons to ImageList Control and then assign the ImageList Control to Imagecombo

Ryan ChongSoftware Tead Lead / Business Analyst / System Analyst / Data Engineer

Hi ramses,

Some useful link here:

Retrieving the List of Registered File Associations: http://www.mvps.org/vbnet/code/reg/regfileassociations.htm

'Hope will help.

TimCotteeHead of Software Services

Well it is possible, you need to examine the registry under HKEY_CLASSES_ROOT to identify the registered file types, determine where the icon is, extract the icon from the appropriate file, add this to an image list, and add the filetype(s) to the treeview.



The approach you sugested is approved by me for retrieving the list.  

For compatibility issues, I do not wish to read the registry directly.  If for example, some information is found under HKCR\blahablah, and I implement it, then distribute the program and one some other os (maybe with future releases or something) they've moved the location of that information to another branch.  At that point the program will fail.  But, if I use an API call, like provided by rayncys, I'm comfort that ms will adjust that api to reflect the new locations.  If you know what I mean.

Now then, since I've determined not to read the registry directly, I need a way to get the ICON of the filetype.  The way I want to implement it is by using an ImageList.  The function that will collect all data (filetypes, description and icon) has to place the icons in an imagelist at the position that...AAARGH!  I'll give the example in some pseudo code:

Private Type FileType
  Extension As String
  Description As String
End Type

Function GetFileTypes(byref ImageList1 as ImageList, byref FileTypes() as FileType) As Boolean


IF SUCCESSFULL Return True else False

End Function

   (0) .Ext = first filetype extension
   (0) .Description= first filetype description
   (0) = first filetype icon

I don't know how to express myself correctly, but I hope you get the drift.

Take a look at the sample on this page:

"SystemImagelist: How to associate the system imagelist with the VB ListView"



1) your code doesn't work
2) I think you misunderstood me.

What I want is to have a listview list all available filetypes, allong with their icon.  Information about DDE is not required in this step, but is appreciated.

Basically, what I want to do is provide the user with a list of all registered filetypes on their pc, and to add some more clues to the user what a filetype stands for, include it's icon.  

The datamodel I provided was just to give you an idea how it's going to be processed.  But I can do the processing myself, I just need the data to be gathered.

So  this is what I want:

API for Obtaining all registered filetypes, with extension and description and icon.
API for extracting icons from EXE file

>>your code doesn't work

Well, its not my code, but the sample runs just fine for me.  What problems did you have?

I understand what you are after, and I want you to realize that the only way to enumerate these items and get their associated icons is via the registry.

>>The approach you sugested is approved by me for retrieving the list.  
>>For compatibility issues, I do not wish to read the registry directly

You are contradicting yourself, since the method for enumerating file types is reading the registry.  I doubt seriously that MS will alter the HKCR section of the registry any time soon, if ever, in their OSes.  Their shell assumes this is where the information is stored, and they are aware of the countless programs that also make the same assumption.


I'm not actually not refering to this registry setting, I just wanted to make a point never to read registry directly, but always use API calls (I know reading registry is also via API, but you know what I mean) that retrieve the values.  Where they come from, I don't care.  For those of you familiar with Electronics, I'll consider this the "black box": the only thing that's of importance is what goes in and what comes out.  What the box does, we don't know, and we don't want to know.  So in my programs, I always look for the API call that will provide the information or functionality, instead of reading/writing it to the registry myself.

The code breaks with some missing ocx that's not in the archive Arazsound.

I don't want to start a discussion here on which approach is better, I just want to let you know that I prefer the API call instead of reading it directly.  

What I have now is Enumerating filetypes to get extension and description.  Now I need to add routines to get the icon, AND, if necessary how to extract the icon from the executable.  For example if it says icon=somefile.exe,3 I need to know how to get to that 3rd (or is it 4th?) icon.

>>The code breaks with some missing ocx that's not in the archive Arazsound

It should open up your References dialog and indicate a missing library.  Just uncheck it and then run it again.


hold on, I'll give it a go


Thanks Azrasound!

Ryancys, I hope you don't feel bad that I choose AzraSound's approach.  Your's a valid too, but this is a all-in-one solution that's not only functional, but also FASTer than your's

Glad we could help   :-)

Explore More ContentExplore courses, solutions, and other research materials related to this topic.