博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
WPF获取外部EXE图标最简单的方法
阅读量:7008 次
发布时间:2019-06-28

本文共 405 字,大约阅读时间需要 1 分钟。

原文:

首先在工程添加对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://gxjtl.baihongyu.com/

你可能感兴趣的文章
CollectionUtils简单学习
查看>>
千万级规模高性能、高并发的网络架构经验分享
查看>>
交换机的基本概念和配置
查看>>
longestCommonSubstring
查看>>
关于C#调用大漠插件时提示“{26037A0E-7CBD-4FFF-9C63-56F2D0770214} 的组件时失败”的解决办法...
查看>>
go语言学习--pongo2 fasthttp fasthttprouter pgx
查看>>
Linux Shell sort按照指定的顺序进行排列
查看>>
android Bitmap类方法属性 详细说明
查看>>
我的友情链接
查看>>
China Azure 在HDinsight 中使用Spark 功能
查看>>
sqlserver 2008 R2 审计
查看>>
mysql常用脚本
查看>>
在windows server 2012R2上卸载服务
查看>>
第 10 章 容器监控 - 085 - 如何快速部署 Prometheus?
查看>>
计算机行业小总结
查看>>
POJ-3140 Contestants Division[树形dp]
查看>>
linux开发核心理解
查看>>
Pom报错
查看>>
elasticsearch内存优化设置
查看>>
python 线程
查看>>