Thread: A new project?
View Single Post
Old Oct 5th, 2005, 8:58 AM   #10
Rory
Expert Programmer
 
Rory's Avatar
 
Join Date: Jan 2005
Location: London
Posts: 542
Rep Power: 4 Rory is on a distinguished road
Send a message via MSN to Rory
There does seem to be little point in writing yet another file manager, but...

I'd use ExtractAssociatedIcon which will return a pointer to an icon resource and requires the path of the file/drive/folder, and some parameters dictating the size, style (icon, thumbnail etc) - check msdn for the details. Then you can paint straight to a valid DC with this pointer using DrawIcon, so if you're using the ListView control you can paint straight to the DIBs in that or an attached ImageList control, but if you prefer you could marshal it as a .NET bitmap first and paint using the GDI+ (which seems to give little benefit at a high speed penalty).

I followed this API approach for a web-based directory lister that showed specific as opposed to generic filetype icons, but I bet there's something built in to .NET that'll get the explorer file icons for you, as its quite a common task. Dameon?

Of course if it was going to be a proper file manager not relying on explorer, you'd generate the icons yourself like konqueror.
Rory is offline   Reply With Quote