views:

77

answers:

3

I am developing an application that will be running behind the scenes in Windows and would like to put an icon in the system tray for troubleshooting purposes (simple way for users to tell if the app is running). There is no other UI for the application, and the icon does not need to have any functionality as of right now.

All of the solutions I have found as of yet involve creating a form. I am wondering if there is a way to simply add a class to my current C# code that allows me to control the icon, rather than doing the whole 'make a form, set it to be invisible....' nonsense that seems to be the popular suggestion on the forums. Something along the lines of the way that UI control is done in say, Swing for Java. I would really appreciate any ideas!

(Sorry if this is a n00b question...I haven't used C# before...)

Thanks!

badPanda

+1  A: 

For Windows Forms:

Form.ShowInTaskbar to show/hide in the taskbar

and use a NotifyIcon to show in the tray

simendsjo
@simendsjo, what is your executing context? a Console application, [hidden] WPF application, or WindowsService? i believe badpanda was looking specifically for something that avoids the hidden WPF application model. will this work with a WindowsService application?
johnny g
Should have noted my solution was for Winforms...
simendsjo
+4  A: 

You can do it with a custom ApplicationContext. Google reveals first this tutorial on how to achieve it. Or you can alter your main Program file not to show any form at all:

Application.Run(); //remove the Form oject from this call
Adrian Faciu
+1  A: 

From whatever project you use, why not just create an instance of the NotifyIcon class and use it to display the icon in the system tray?

Chris Dunaway