B4J Question B4J Windows service: background app, but with UI

peacemaker

Expert
Licensed User
Longtime User
Hi, All

If we need stable working always in memory background app under Windows, it means
1) minimal setting interface window after tray icon menu click
2) and background work as a Windows service

What is actual variant in 2024? Code example ?
 

DonManfred

Expert
Licensed User
Longtime User

Services in Windows can not have any UI.
To have a trayicon you have to run an ui-app with tray-icon which should interact with the service.

I don´t know to do all these steps in B4X. And i fear it will be a hard task.

It is possible but you have to do some Steps to solve.
To create an interactive service, do the following when calling the CreateService function:


  1. Specify NULL for the lpServiceStartName parameter to run the service in the context of the LocalSystem account.
  2. Specify the SERVICE_INTERACTIVE_PROCESS flag.

To determine whether a service is running as an interactive service, call the GetProcessWindowStation function to retrieve a handle to the window station, and the GetUserObjectInformation function to test whether the window station has the WSF_VISIBLE attribute.


However, note that the following registry key contains a value, NoInteractiveServices, that controls the effect of SERVICE_INTERACTIVE_PROCESS:

PD: I for myself would not use Java (or B4X) to build a Windowsservice.
 
Last edited:
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
Create an installable package and add the function to enable your app on the starting apps.
 
Upvote 0

tchart

Well-Known Member
Licensed User
Longtime User
The pattern I use is to have a jetty web server as part of the service. You can use web sockets or REST to send commands to the app. For example if I need to restart the app I have an html page that allows me to do this.

I deploy my service using this;


I use WinRar to create an installer for the app.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks for reply. But it looks "not easy" to follow up. I mean, there is no any detailed, the full test project example with all files in a bundle to download, see, compile, setup, edit settings...
 
Upvote 0
Top