Results 1 to 20 of 25

Thread: Creating a service, Windows 10, Qt 5.4.1,

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2014
    Location
    USA
    Posts
    85
    Thanks
    17
    Thanked 2 Times in 2 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Creating a service, Windows 10, Qt 5.4.1,

    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.
    Attached Files Attached Files

Similar Threads

  1. How do I create a Windows Service in Qt?
    By ayanda83 in forum Qt Programming
    Replies: 1
    Last Post: 11th September 2017, 12:16
  2. How to install a service in windows with automatic startup?
    By josecarlosmissias in forum Qt Programming
    Replies: 0
    Last Post: 11th December 2009, 17:01
  3. Start Qt application as Windows Service
    By ^NyAw^ in forum Qt Programming
    Replies: 12
    Last Post: 10th May 2008, 17:23
  4. Creating QDS service
    By bowser in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 29th October 2007, 11:12
  5. Windows Service
    By TheGrimace in forum Qt Programming
    Replies: 3
    Last Post: 5th October 2007, 19:46

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.