Get application icon of C# WinForms App

淺唱寂寞╮ 提交于 2019-12-10 02:21:49

问题


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?

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.


回答1:


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.



来源:https://stackoverflow.com/questions/25403169/get-application-icon-of-c-sharp-winforms-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!