Programmatically change the program icon

北慕城南 提交于 2019-12-11 10:24:11

问题


I'm developing on VS 2010/ C#.

Does any one know how to change the software icon programmatically?

I actually want my software to have one icon under Windows 7 and another for Windows XP in the same software installation.


回答1:


If it's a winform app, you can write below code in the formload event of the main form.

Use this link to find operating system : http://andrewensley.com/2009/06/c-detect-windows-os-part-1/

and then write below code to set icon.

private void InvestorReportingFormLoad(object sender, EventArgs e)
        {
            this.Icon = Properties.Resources.coins;            
        }



回答2:


 this.Icon = Icon.ExtractAssociatedIcon(@"Stringpath");


来源:https://stackoverflow.com/questions/12059066/programmatically-change-the-program-icon

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