Results 1 to 3 of 3

Thread: Get Default Icon for File based on extension

  1. #1

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186

    Get Default Icon for File based on extension

    I'm getting the file names off of a FTP server, and using the three rightmost non-null characters as the extension. i know not all extensions are three characters, but for the moment, this is irrelevant.

    so im doing FTPFINDFIRSTFILE and INTERNETFINDNEXTFILE, trimming off all the Chr$(0)'s and adding the filename and extension to an array. I then filter through the array, assigning static icons to some file types (HTM, CSS, JS, etc). They are then assigned to a ListView.

    But if it doesn't recognize the extension, I have it set to use the default Wordpad .DOC icon, the one that is uglier then penguin faeces.

    How can I do this? I don't want to go through WIN.INI since not all icons are available. I think it would be easy enugh if the files were local and I could get a handle for 'em, but all I have to work with is an extension from a remote FTP server.
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

  2. #2
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Can't you just create a "dummy" file with the extention you want to find the icon for and then use the ExtractAssosiatedIcon on that file?
    Code:
    'the extention is in the sExt string
    'Declarations void
    hFile = FreeFile
    Open "c:\Dummy." & sExt For Output As #hFile
    Close #hFile
    hIcon = ExtractAssociatedIcon(App.hInstance, "c:\Dummy." & sExt, 0)
    Kill "c:\Dummy." & sExt
    Then use DrawIcon to draw it on a hidden picture box and then add the image to an ImageList.

    Best regards

  3. #3

    Thread Starter
    Addicted Member bbosh's Avatar
    Join Date
    Oct 2000
    Location
    Hell (AKA New Mexico)
    Posts
    186
    Thanks, I kept thinking about doing it that way but never actually tried.
    Brian
    Programming: VB5 Pro (SP3) - QBasic 1.1,4.5
    Internet: HTML 4, CSS, JavaScript
    Visit AltInt.com!

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