获取C#WinForms App的应用程序图标 [英] Get application icon of C# WinForms App
问题描述
我已使用项目属性选项卡为C#WinForms应用程序分配了一个图标。此图标与构建时的程序清单一起提供。有没有办法在运行时获取此图标的 System.Drawing.Icon
对象,而无需再次将其嵌入资源中?
I've assigned an icon to a C# WinForms app using the Project Properties tab. This icon is supplied along with the program manifest at build time. Is there a way to get an System.Drawing.Icon
object of this icon at runtime, without having to embed it in resources again?
我做了我的研究;有一种方法可以从EXE中提取图标,但我无法从应用程序中找到从正在运行的C#应用程序中提取图标的任何内容。
I've done my research; There's a way to extract an icon out of an EXE, but nothing I can find to extract the icon off the running C# application from within the application.
推荐答案
您是否看到了第二个答案在链接? (如何从可执行文件中获取只有C#中进程的实例的图标)
Did you see the second answer in the link? (How can I get the icon from the executable file only having an instance of it's Process in C#)
//Gets the icon associated with the currently executing assembly
//(or pass a different file path and name for a different executable)
Icon appIcon = Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location);
这似乎正在获得正在执行的程序集的图标。
That seems like it's getting the icon for the executing assembly.
这篇关于获取C#WinForms App的应用程序图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!