首先在工程添加对System.Drawing的引用

创建以下方法:

public static ImageSource GetIcon(string fileName)
{
    System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon(fileName);
    return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
                icon.Handle, 
                new Int32Rect(0,0,icon.Width, icon.Height),
                BitmapSizeOptions.FromEmptyOptions());
}

在WPF窗体添加一个Image控件

就可以调用了:

this.image1.Source=GetIcon("C:\\test.exe");

转自:http://blog.csdn.net/soft2buy/article/details/6979351

相关文章:

  • 2021-06-11
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-05-23
猜你喜欢
  • 2021-10-21
  • 2022-12-23
  • 2021-07-30
  • 2021-06-18
  • 2021-04-07
  • 2021-06-08
  • 2021-06-17
相关资源
相似解决方案