没有WinAPI的获取相关的文件,文件夹或驱动器图标 [英] Get associated icon from file, folder or drive without WinAPI

查看:114
本文介绍了没有WinAPI的获取相关的文件,文件夹或驱动器图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法让在C#中的相关图标,而无需使用任何DllImports?

Is there a way to get an associated icon in C# without using any DllImports?

当我使用Icon.ExtractAssociatedIcon我似乎并没有得到的驱动器,文件夹,SpecialFolder在环境或任何文件的网络附加文件夹的图标。那么,有没有其他办法使用.NET来得到一个图标?

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?

推荐答案

净只有一个方法,提取相关图标,你已经提到了。每一个库,你可以找到用途pinvokes,因为他们得到的图标,从窗户。所以,如果你需要完全便​​携的图标提取引擎,你必须把它写自己,可悲的是,但是这是唯一的方法(和隐藏所有系统的具体code内)。​​

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

这篇关于没有WinAPI的获取相关的文件,文件夹或驱动器图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆