views:

126

answers:

3

Hi Freinds, for extracting special folder icons I'm using

ExtractIconEx(Environment.SystemDirectory + "\\shell32.dll",ncIconIndex, handlesIconLarge, handlesIconSmall, 1);

Here im passing explicitly nIconIndex for special folders like MyDocs,MyPictures ..etc and its working fine in XP ,however in Vista its not retrieving the correct icons ..there it retrieves yellow folder icons..it should not be the case. Cn anybody help me on this..

+1  A: 

Check out the IconLib library at codeproject.

arul
While IconLib is beyond compare for handling and extracting icons from files icons in .NET, I don't think it does what Anees is asking, which is obtain the icon from the Windows shell API for a special folder.
Michael McCloskey
You are absolutely right Michael..thanks
Andy
A: 

The best example I've seen of success in this area from .NET (and it was done with VB.NET) is in this article.

http://www.codeproject.com/KB/cpp/VbNetExpTree.aspx

My $.02 is that working with the shell API is extremely painful from .NET due to the level of COM interop required and the complexity of the API's.

Michael McCloskey
A: 

Vista added a new API called SHGetStockIconInfo but it does not support my documents AFAIK. But that does not matter since the method you SHOULD be using works on both XP and Vista (Your current solution will not work when the user has selected a custom icon, you are just looking in hardcoded system dlls, this could change at any point)

So, what you should do is, get the path or PIDL to the shell folder you are interested in (SHGetFolderPath and friends) and pass that path/PIDL to SHGetFileInfo. SHGetFileInfo can give you a icon handle, or the index into the system image list.

I'm not sure what the .NET equivalent for those functions are, but you should be able to figure that out, or use PInvoke

Anders
thanks Anders... i think i can i do tht
Andy