Get associated icon from file, folder or drive without WinAPI

江枫思渺然 提交于 2019-12-12 08:40:04

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!