CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Apr 2001
    Posts
    126

    Any way to get File icons?

    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.

  2. #2
    Join Date
    Oct 2002
    Location
    Växjö, Sweden
    Posts
    225
    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

  3. #3
    Join Date
    Apr 2001
    Posts
    126
    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.

  4. #4
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868
    Search the VB forum, I posted an example there not long ago.

  5. #5
    Join Date
    Oct 2002
    Location
    Växjö, Sweden
    Posts
    225
    aha, sorry. Me and english sometimes. Cant you still use a shell32.dll API?

    /Leyan

  6. #6
    Join Date
    Apr 2001
    Posts
    126
    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?

  7. #7
    Join Date
    Apr 2001
    Posts
    126
    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/de...on/Extract.asp

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured