PDA

View Full Version : QtService example interactive not running



TonyInSoMD
12th March 2018, 17:25
I'm creating a qtservice that has a gui for doing log in/log out. I modeled it after the example "interactive" in the examples folder. Instead of QLabel I use a gui I wrote. It won't run. When I try to start it the process shows up in the process list, but it time outs. I tried running the interactive example in the qtservices folder which is supposed to show a QLabel with "Service" as the text. The service installs (-i), the service starts (-s) and shows that it is running and the process is there in the process list, but there's no label. What in the heck could I be doing wrong that even the example doesn't run? I'm running in Administration window.

d_stranz
13th March 2018, 04:36
What in the heck could I be doing wrong that even the example doesn't run?

Having a bad month, maybe?

I have never messed with trying to create and Windows service. I'm wondering if you could find a non-Qt service example, maybe on the MSDN site (like this one (https://msdn.microsoft.com/en-us/library/windows/desktop/bb540476(v=vs.85).aspx)), that you could get working. Services normally run without a GUI, so I also wonder if there is a flag you are missing in the command line that says "run interactively", and without it, you get a background process.

But then there are these lines from the Qt Solutions QtService "interactive" example:



void InteractiveService::start()
{
#if defined(Q_OS_WIN)
if ((QSysInfo::WindowsVersion & QSysInfo::WV_NT_based) &&
(QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA)) {
logMessage( "Service GUI not allowed on Windows Vista. See the documentation for this example for more information.", QtServiceBase::Error );
return;
}
#endif


Windows 7 and 10 certainly pass the >= WV_VISTA test, so you'll see a log message and no GUI.

ChrisW67
13th March 2018, 06:57
You will need at least one other option on the service for this to have a chance of working:

Install the service
Open the services panel
Go to the service properties page
Click on the "Log On" tab
Select "Local System account"
Check "Allow service to interact with desktop"



More here (https://stackoverflow.com/questions/897568/starting-a-windows-service-in-an-interactive-session) at Stack Overflow

TonyInSoMD
13th March 2018, 11:18
The settings were already like that. Like d_stranz pointed out, you can't use interactive service (the one I need) on Windows 7 soon to be 10. Sorry I missed that, I skimmed over that part and thought it said != instead of =>. I guess I should actually pay attention to what I read. :(

d_stranz
13th March 2018, 16:41
you can't use interactive service (the one I need)

So you might have to be a bit more creative. Implement your service with a port of some sort you can connect to via a non-service GUI client. When the client runs, it connects to this port to send commands to the service. Qt has many options for interprocess communication, pick one that works best for your situation.