1

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.

Cœur
  • 37,241
  • 25
  • 195
  • 267
TEST ME
  • 123
  • 2
  • 9
  • If you are talking about the launcher icon, then your installer is what adds that. So, you need to change your installer, in order to advise further I would need to know what installer you are using. – Justin Harvey Aug 21 '12 at 16:21
  • not regurd to the installation process.. I want that after the installation process I'll get under Windows7 c:\program Files\mysoftware.exe(with Icon1) and under windows XP c:\program Files\mysoftware.exe(with Icon2)... the software do the same action in both OS but I need them to be diffrent Icons... – TEST ME Aug 21 '12 at 16:53
  • This is pretty hard to do, the icon is embedded as an *unmanaged* resource in the EXE. Best approach is to have your installer create a .lnk file with a custom build action. – Hans Passant Aug 21 '12 at 18:05

2 Answers2

3

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;            
        }
sharp_net
  • 737
  • 2
  • 5
  • 12
  • 1
    I don' t think this is the answer because it just changes the form's icon. He asks to change the program icon, or application. – Hao Nguyen May 07 '17 at 18:24
0
 this.Icon = Icon.ExtractAssociatedIcon(@"Stringpath");