My hobbyist coding updates and releases as the mysterious "Mr. Tines"

Sunday 29 July 2007

You move 16 tons...

The gaps in the Win32 API support in .Net are random and frustrating. You can get all the drive letters (and the "DriveType" or "MediaType" properties which together give the offset into Shell32.dll for the drive icon), but short of unpicking the PE format by hand, Google gives no way to get the icons without using P/Invoke.

So with a combination of existing recipes for wrapping SHGetFileInfo in C#, and feeding it through Fuzzyman's dynamic compiler utility, I have some approximately script-like behaviour for icon extraction -- as can be seen from the left-hand dropdown in the screenshot.

I still need to add some extra hooks to use SHGetFileInfo to check if a file is executable or not, so I can get custom icons, and then refactor out a proper utility. And there's still more work on the generic directory pane widget before it'll be something stand-alone (sorted file list, hooking up events); though I hope that should not require any more exploting of exotic APIs to achieve.

No comments: