Closing the task tray application

I have a set of server applications that run in the taskbar. I am trying to write a small server management application in C # that can gracefully close applications. However, it’s hard for me to figure out how to do this.

I can get the process (an instance of the Process class). The call to Process.CloseMainWindow () does not work. You do not get Process.MainWindowHandle for the task tray process (it is zero and is documented that it is), so I cannot send, say, the message WM_SYSCOMMAND, SC_CLOSE.

I can kill (), but it's not elegant. Any ideas? Server applications are written in Delphi Win32. I can change them.

+4
source share
2 answers

You can use pipe to send them messages.

+2
source

You can iterate windows using EnumWindows to find the hidden window associated with the tray icon. This is all pretty ugly and error prone. Do it cleanly, create these "server applications" named pipe. You can connect to them in your manager application using a known name, and then send them a command. System.IO.Pipes namespace.

+2
source

All Articles