Anees
Anees

Reputation: 873

Icon Extraction in VIsta

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..

Upvotes: 1

Views: 551

Answers (3)

Anders
Anders

Reputation: 101764

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

Upvotes: 1

Michael A. McCloskey
Michael A. McCloskey

Reputation: 2411

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.

Upvotes: 0

arul
arul

Reputation: 14094

Check out the IconLib library at codeproject.

Upvotes: 1

Related Questions