我已使用“项目属性”选项卡为 C# WinForms 应用程序分配了一个图标。该图标在构建时与程序清单一起提供。有没有办法获得System.Drawing.Icon
在运行时获取此图标的对象,而无需再次将其嵌入资源中?
我已经做了我的研究;有一种方法可以从 EXE 中提取图标 https://stackoverflow.com/questions/304109/getting-the-icon-associated-with-a-running-application,但我找不到任何东西可以从应用程序内提取正在运行的 C# 应用程序的图标。
您看到链接中的第二个答案了吗? (如何从 C# 中只有进程实例的可执行文件中获取图标 https://stackoverflow.com/questions/203456/how-can-i-get-the-icon-from-the-executable-file-only-having-an-instance-of-its)
//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);
看起来它正在获取正在执行的程序集的图标。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)