We have an existing C++ application which uses WinAPI (let's call it "SvcApp"). We have another C++ WinAPI application called "MgrApp" which installs and starts "SvcApp" as a Windows service.
However, we'd like to replace "SvcApp" with a Qt application. I may be misinformed, but it seems like it's not possible to use <windows.h>
from a Qt application, so it seems that I can't just copy and paste all the existing code from "MgrApp"... or can I?
To summarize, we need to do the following from our Qt app:
There's already a solution for that - QtService
.
Documentation here: http://qt.nokia.com/doc/solutions/4/qtservice/
Download here: ftp://ftp.qt.nokia.com/qt/solutions/lgpl/qtservice-2.6-opensource.zip
You definitely can use Windows API (including windows.h) in Qt Applications. Behind the scenes Qt uses the Windows API. The normal way cross-platform Qt apps are handled is by using #ifdef blocks. Qt provides macros like Q_OS_WIN32 and Q_WS_MAC for this purpose. Look through the Qt source code and you will see this method used all over the place.
EDIT: You may also want to look into using the command line utilities for installing/uninstalling and starting/stopping windows services. This way you can just use a QProcess to call it, and not have to delve into the WinAPI (which is always nice)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With