Qt used to have a way to create a service, but they deprecated it with Windows Vista. I did some searching around for a couple of days, worded my search right, and found a method to create a service step-by-step with code on the Microsoft site. There's 4 parts to it, the first step is to create a definitions dll. No problem. You do it command line without opening visual studio. You then create a c++ empty project. Then you add the Svc file, add the definitions library to the project, and you're done as far as creating and starting an empty service. There are other programs form configuration, etc. but as far as installing the service, they are not needed though you will need to run svcconfig delete SvcName to take the service back out. If you going to "play" with it, this is the address of the Microsoft site. https://docs.microsoft.com/en-us/win...service-sample. If I open Visual Studio, create an empty project, add the Svc.cpp file and the sample.dll, compile it, it works fine. So that a could add a Qt class to do the work, I made a Qt console application, copied in the Svc.cpp file and the sample.dll and removed the Qt main. I didn't add any other code to it or anything, it's the same project only with Qt's VisualStudio addin. When I run it to try to install the service, (Svc.exe install), I get the error code ERROR_ACCESS_DENIED when I try to open the ServiceManager "OpenSCManager(NULL,NULL,SC_MANAGER_ALL_ACCESS )". I tried doing the empty project and then adding all the paths, etc and include (but not use) the class, it says I can't do it because I didn't use the Visual Studio add in. I really need this to run as a service so that SysAdmin can control access and so that it will run in the background even in screen-lock mode. I've tried to give enough information, I hope somebody can help me. I attached a copy of the 3 programs written from an empty project that work, the Svc.cpp code, and the sample.dll . The dll is just a set of error definitions, it doesn't really do anything. I didn't know qtcentre wouldn't allow you to upload dll or exe, but it makes sense. I attached all files to create the programs so that you can see what they look like without having to hunt around and without making this post a mile long. The only one I'm having problems with is the Svc.cpp program. The others don't have to be compiled in a Qt environment.
Bookmarks