Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows Service + Run application in System Tray

I have a Delphi application running in a server. This application do some critical work with my DB which is used in other applications and executes when a user logs in to Windows. It all is working fine, but, turns out the server's administrator sometimes reboot the server and does not log in to Windows. The server stays in Windows Login and my application doesn't start.

After a small research I decided to create a Windows Service to start my application even before a user logs in Windows. But, I have two forms. One form shows the Current Process that my application is executing and the other one edite a .ini file that its used to configure the first form.

What I need to be done is to create a service that starts my application before a user logs in Windows and after logging in, show my forms or open it but minimize it to System Tray.

Is it possible to use Windows Service with this behavior and minimize my forms to the System Tray?

like image 730
Daniel Avatar asked Dec 04 '22 14:12

Daniel


2 Answers

A service cannot display a UI at all (including a System Tray icon) in Vista onwards, and it is discouraged in earlier versions. In all versions of Windows, you should be separating the UI out into its own non-service application that can be run by a logged-in user, manages the system tray icon for that user's tray, and communicates with the backend service as needed using any number of available IPC mechanisms (pipes, sockets, COM, RPC, WCF, etc).

like image 122
Remy Lebeau Avatar answered Dec 28 '22 05:12

Remy Lebeau


Well, you can have a form in a service, but is has to run as Administrator and must be set up as an interactive service.

I've used SVCOM to create nice services with tray icons and a form that can minimize to system tray.

Have a look here: http://www.aldyn.ru/products/index.html

Hope this helps

like image 26
Peter Vrist Avatar answered Dec 28 '22 05:12

Peter Vrist