-
Jun 22nd, 2001, 10:09 PM
#1
Thread Starter
Addicted Member
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!
-
Jun 23rd, 2001, 04:43 AM
#2
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
-
Jun 23rd, 2001, 02:14 PM
#3
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|