Click to See Complete Forum and Search --> : Any way to get File icons?


Xaeryan
October 24th, 2002, 09:59 PM
I have a listview which displays files in a directory. How can I load the files' associated icons into the listview when I add them? I already can get the file's type (taken from the registry) if that helps any... Thanks.

Athley
October 25th, 2002, 01:23 AM
Even if we where to present a solution to get the files that has a separate .ico file there will still be the once with the icon hard coded into the file itself. I cant see a way to get passed them.

/Leyan

Xaeryan
October 25th, 2002, 11:00 AM
I think you misunderstood - I just want to diplay the icons like Windows Explorer does. It IS possible to do, I've done it in VC++ and VB, but now I need to do it in VB.NET and I can't find any documentation... I need to use the functions GetIconLocation which gets the location and index of a file's icon (whether it be in that file, or in a separate .dll), and then the Extract function, which extracts that icon. Unfortunately, MSDN only has these documented very generally (not for .NET) and I can't adapt it...
Search MSDN for GetIconLocation and you'll get a better understanding of what I need.

DSJ
October 25th, 2002, 11:04 AM
Search the VB forum, I posted an example there not long ago.

Athley
October 25th, 2002, 12:27 PM
aha, sorry. Me and english sometimes. Cant you still use a shell32.dll API?

/Leyan

Xaeryan
October 26th, 2002, 12:51 AM
It would be possible to use shell32, but the SHGetFileInfo, although easy, is way too slow. Microsoft even refers to GetIconLocation and ExtractIcon as better, more effecient ways to do this.
Their must be some simplified way to do this in VB.NET, though. Maybe an import which has these functions in it somewhere?

Xaeryan
October 26th, 2002, 01:01 AM
DSJ: That will work, but it is also too slow for what I need... and I can't figure out the ExtractIcon API anyway.

Can anyone explain how to use shell "Interfaces" in VB.NET? The ones I need to use are IExtractIcon:ExtractIcon and IExtractIcon:GetIconLocation. These seem to be the easiest and most efficient methods, and can return both the large and small icon for a file.

MSDN documentation can be found here, if anyone can understand how to use it better than me: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/ifaces/iextracticon/Extract.asp