解决了!有关工作代码,请参阅编辑2.
基于此站点的代码和freundblase在同一站点中完成的注释,我有以下类来获取基于文件扩展名的jumbo默认图标:
// Original bad code removed
Run Code Online (Sandbox Code Playgroud)
我正在尝试以下列方式使用该类:
preview.ImageSource = IconManager.GetIcon(".pdf", true);
Run Code Online (Sandbox Code Playgroud)
其中预览是一个ImageBrush对象.
但我得到以下图像:

是的,我尝试使用pdf文件等注册文件类型.
怎么了?
TIA
-
编辑1:
我认为该图标用于未注册的文件类型.
如果我使用实际文件,我会得到一个FileNotFoundException.
-
编辑2:
在发布此问题之前,我使用ReSharper进行了代码清理.
我根据站点代码和freundblase评论再次上课,现在它正在运行!
我必须仔细分析ReSharper所做的更改.代码清理从来没有给我任何问题.
对于后代,以下代码有效:
public class IconManager
{
// Constants that we need in the function call
private const int SHGFI_ICON = 0x100;
private const int SHGFI_LARGEICON = 0x0;
private const int SHGFI_SMALLICON = 0x1;
private const int SHIL_EXTRALARGE = 0x2;
private const int SHIL_JUMBO = 0x4;
private const int WM_CLOSE = 0x0010;
// This …Run Code Online (Sandbox Code Playgroud)