views:

258

answers:

2

I'm trying to add different icon overlays over the icons of various files (note: not all the files of a certain type, just certain files). If you don't get what I mean, I'm referring to what programs like TortoiseSVN, TortoiseHG, Dropbox, etc. do.

Can this be done in .NET? If so, how? I'm hoping there's a library out there for this. I found this CodeProject article about something like this, but it's not .NET.

Thanks in advance.

+3  A: 

No, it's not .NET. Shell programming is in the domain of unmanaged C/C++. Shell32.dll has a type library that makes some functions available to scripting languages and .NET. But the IShellIconOverlay interface inherits from IUnknown, not accessible to scripting. It is technically possible but you'll have to redeclare the interface in C#, using the declaration in the SDK's ShlObj.h header file as a template. Somebody has done it somewhere, probably, but it is uncommon to try to make it work. A quick Google search turns up nothing useful.

Hopefully, .NET 4.0 will revive some activity, solving the CLR version injection problem. I haven't yet seen a sign of it.

Hans Passant
+3  A: 

The interfaces to be used are described here, and the P/Invoke wiki has even a declaration for it.

However, I don't know of a concrete C#/.net implementation of that.

Lucero
Your SetOverlay() method has a ListView input: this is confusing me. Is it possible to somehow pass in a file path and apply an overlay (with an image path as a parameter) through your code? Thanks!
Maxim Zaslavsky
Why'd you remove your code btw?
Maxim Zaslavsky
@Maxim Z. I removed it because I first misunderstood the question. My code was for using overlay icons on a inprocess listview, not in the windows shell. Sorry about that. For the shell, you need to implement the `IShellIconOverlayIdentifier` as COM object which is registered in a special way so that Explorer uses it.
Lucero