问题
Is there a way to get an associated icon in C# without using any DllImports?
When I use Icon.ExtractAssociatedIcon I don't seem to get the icon for drives, folders, SpecialFolder's in Environment or any files on network attached folders. So is there any other way to get an icon using .NET?
回答1:
.Net have only one method for extracting associated icons, and you already mentioned about it. Every lib you can find uses pinvokes, because they get icons from windows. So if you need to fully portable icon extraction engine, you must write it by yourself, sadly, but this is the only way (and hide all system specific code inside).
回答2:
Not an answer to your question but might be of use.
You can get most of ms windows icons from this file
$VisualStudiosInstallationDirectory\Common7\VS2008ImageLibrary\VS2008ImageLibrary.zip
Substitute 2008 for 2005 if you still use VS2005
来源:https://stackoverflow.com/questions/999837/get-associated-icon-from-file-folder-or-drive-without-winapi