views:

18

answers:

1

I'm trying to write a monitor app for Dream Daemon, a specific server app. Since the server app tends to crash (specifically, Dream Daemon is a server for a specific brand of interpreted code, so it's the interpreted code that's crashing, leaving DD idling).

To avoid people having to manually log on and restart the thing several times a day after the code we have it running crashes or glitches badly, I'm trying to set it to where an automatic monitor will check to see if the server's failed, and then close and restart the program. Because of some specific behaviour in Dream Daemon, I can't use a process.Close() call since DD intercepts that and simply minimizes itself to the system tray. If I process.Kill(), I end DD, but that leaves an orphaned notify bar icon left showing. I'm wondering if there is a way for me to then remove that icon programmatically, so my monitor program can clean up after itself.

+1  A: 

Since it's a server that noone might be logged into I'm not sure if I'd worry too much about the icons lingering, but if you really want to remove them I don't think there's a nice way of doing that. The only way I know of refreshing the systray is to move the mouse over the icons in it.

You could of course write code to simulate moving the mouse over icons which should work the same way. So since you don't know which icon to refresh you'd need to find the systray, get it's location and dimensions and then simulate a mouse move right across it.

Here's an article with sample code (in C++, but since it's fairly short it shouldn't be too hard to convert to C# or similar if needed) for doing this.

ho1