Displaying icons for registered file types

G

Gwyn

Howdy. In my vb.net application I want to populate a
listview with a list of files but I also want to show the
icon for those files according to the registered file
types on the user's computer, e.g. if I list a file with
a .doc extension I want a pretty Word icon next to it....

But how do I populate a listview with the required icons?
Is there help in .NET to do this or do I need to search
the registry? If so, where???!!!!

Thanks in advance to anyone who can help!
 
N

nickp

Gwyn,
You will need to the System.Runtime.InteropServices namespace and P/Invoke some Win32 code, basically you will be calling SHGetFileInfo and using a SHFILEINFO structure. The following link provides an article for exactly what you are looking for. Hope this help.

http://www.codeguru.com/vb_misc/HowToUseVB.html

-Nick Parker
 
G

Guest

I suspected as much. Yuk! (trying to avoid native stuff).
But how do I get the correct files to retrieve the icon
from... I've tried looking in the registry to get the
default icon for extensions but I can't, for example, find
a path from the .doc key to the class id that has the
defaulticon key from where I can get the file to go look
in..

Thanks so far... any more would be great!

This is quite a common requirement... it should be
provided in the framework...
-----Original Message-----
Gwyn,
You will need to the System.Runtime.InteropServices
namespace and P/Invoke some Win32 code, basically you will
be calling SHGetFileInfo and using a SHFILEINFO
structure. The following link provides an article for
exactly what you are looking for. Hope this help.
from .NET's Largest Community Website:
http://www.dotnetjunkies.com/newsgroups/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top