问题
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.
回答1:
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.
来源:https://stackoverflow.com/questions/2496582/net-how-do-i-create-file-icon-overlays