Changing my application exe icon at runtime programatically

Question

Saturday, May 16, 2009 6:07 PM

can i change my applicatipn exe icon from one to another at runtime programatically?
for example:
if i create an application with C# 3 to check the time, and i make a condition like that:

(if the time is am)
{
    the application set the exe icon to icon1.ico 
}
else
{
    the application set the exe icon to icon2.ico
}

is that clear?
is that possible?

All replies (4)

Saturday, May 16, 2009 6:30 PM âś…Answered

Is it form icon? The icon displayed in the top left corner.

this.Icon = new System.Drawing.Icon("shuttle.ico");


Thanks,
A.m.a.L
.Net Goodies
Remember to click "mark as answered" when you get a correct reply to your question

Thursday, May 21, 2009 5:20 PM

Is it form icon? The icon displayed in the top left corner.

this.Icon = new System.Drawing.Icon("shuttle.ico");


Thanks,
A.m.a.L
.Net Goodies
Remember to click "mark as answered" when you get a correct reply to your question

This code is belongs to form icon that appears in the title bar of the form as you said,
but I asked about the exe icon, which I see it in folder C:\Documents and Settings\.....\bin\Debug\


Thursday, May 21, 2009 6:02 PM

You try to swap executable icon. it hard to do with .NET, many examples on the web with vb6 and c++, but i found tutorials how to do it, is a C++ / MFC program. You can try to see if you can convert the code to C#. http://www.codeguru.com/cpp/w-p/win32/tutorials/print.php/c12873__1/

http://www.go4expert.com/forums/showthread.php?t=643

kaymaf


I hope this helps, if that is what you want, just mark it as answer so that we can move on


Monday, July 9, 2012 11:12 AM

If it is a Windows Form, to change the leftmost Icon on to the form:

Try the following line of code in the Form_Load Event:

{

this.Icon=new System.Drawing.Icon(@"Mention the path of ICO file!!!");

}

Kind Regards,

Raj Kumar.