Retrieveing file icons - managed vs unmanaged way... RRS feed

  • Question

  • Hi All,


    Was testing 2 ways  of retrieving associated icons from files, one using Icon.ExtractAssociatedIcon, and another using SHGetFileInfo from Shell32.DLL (described in http://www.codeproject.com/cs/files/fileicon.asp ). Measured the speed, and it came ~30 seconds vs ~5 seconds respectively for a pack of just over 1000 files.

    I would expect some difference, given that managed method probably just wraps unmanaged code here, but that seems a little too much, so I'm wondering if there's something I haven't done..

    Monday, September 17, 2007 6:00 PM

All replies

  • From the article's forum list, did you incorporate the post entitled, " A possible performance increase" ?

    Since we can't see how you did this, commenting on what may be happening in the managed version vs unmanaged would most likely bare no fruit.
    Tuesday, September 18, 2007 3:58 PM
  • That article describes a way to speed up the unmanaged version, however, it is already 6 times faster than Icon.ExtractAssociatedIcon(filename); - and that's what I was wondering about.

    My code is pretty simple, it just loops Icon.ExtractAssociatedIcon(filename); over an array of file names, and same for SHGetFileInfo.

    Btw, ExtractAssociatedIcon producing icons ~700 bytes big vs ~400 bytes produced by SHGetFileInfo.

    Tuesday, September 18, 2007 9:14 PM