views:

36

answers:

2

I trying to make a visible tray-icon of my program in windows startup, with the NotifyIcon component.

The program itself works great and the tray-icon showing up.

But, when i placing my program in computer startup, the tray icon not always showing up, while the program itself is running without any problems, and its main window is visible.

There is no custom code involved here, all code is auto-generated.

Running on Windows 7 Ultimate.

What can i do to make the tray icon to showing up in windows startup always?

A: 

in windows startup

If you mean you are running a OS boot time (e.g. by adding an entry to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run or with a service) then the process is running in a different session and has no access to the UI.

If you want a process to be run on OS startup and to be interactive you will need two applications: one to run on startup and expose some form of inter-0process communications (IPC), and two a UI application that uses the first applications IPC to communicate with it.

You also (depending on your target users) may need to consider cases where (1) no-one logs on to the system (e.g. a headless server), and (2) where multiple users login (e.g. remote desktop connections to a shared system).

In the past services could be configured to add items to the console user's UI, but this was blocked in Vista (as it opened up security holes).

Richard
+1  A: 

You'll probably find it back in the hidden icons. On Win7 click the "Show hidden icons" arrow, click on Customize and override the behavior.

Hans Passant
thanks, but this is not the problem, my tray icon is not there either.
DxCK
I don't know, haven't hear of this problem before. See what happens when you put a System.Threading.Thread.Sleep(5000) in the Main method, giving the taskbar enough time to initialize completely.
Hans Passant
Thanks, your suggestion with Thread.Sleep(5000) increased the chance for the tray-icon to show up, still not 100%.
DxCK
Painful, how often did you reboot so far? Never heard of a tray initialization problem on Win7, but that's what it sounds like. Bump up the delay.
Hans Passant