How to get NotifyServiceStatusChange into Qt?
-
Hello,
NotifyServiceStatusChange is a Win32 API function and is available starting with Win Vista.
As far as I see, most XP functions are available but this function isn't:@#include "qt_windows.h"@
@'NotifyServiceStatusChange' was not declared in this scope
NotifyServiceStatusChange bla;
^@Googling' the net, this site came up:
http://stackoverflow.com/questions/7103750/qt-application-dependent-on-windows-serviceIs it possible to use NotifyServiceStatusChange with Qt?
Thanks. -
Hi,
NotifyServiceStatusChange is only available since Windows Vista. See "here":http://msdn.microsoft.com/en-us/library/windows/desktop/ms684276(v=vs.85).aspx
-
I know, my App is for Windows Vista / 2008 and up.
Is there any Macro I need to set to activate >XP APIs in Qt?This is in "winsvc.h":
@#define NotifyServiceStatusChange __MINGW_NAME_AW(NotifyServiceStatusChange)DWORD WINAPI NotifyServiceStatusChangeA(
SC_HANDLE hService,
DWORD dwNotifyMask,
PSERVICE_NOTIFYA pNotifyBuffer
);DWORD WINAPI NotifyServiceStatusChangeW(
SC_HANDLE hService,
DWORD dwNotifyMask,
PSERVICE_NOTIFYW pNotifyBuffer
);#endif /(_WIN32_WINNT >= 0x0600)/@
-
@DEFINES += "WINVER=0x0600"
DEFINES += "_WIN32_WINNT=0x0600"@I added this to my .pro file.
Is this the right way? The whole App is requiring Win Vista. -
It's one way to do it yes, or you can define WINVER before including qt_windows.h in your code
-
Hmm... Function is now available but defines like SERVICE_NOTIFY_STATUS_CHANGE and SERVICE_NOTIFY_RUNNING are missing. They are not present in MinGW "Winsvc.h".
What do I miss?
-
Seems these defines are missing from MinGW. You can define them yourself
@
#ifndef SERVICE_NOTIFY_STATUS_CHANGE
#define SERVICE_NOTIFY_STATUS_CHANGE 0x2
#endif
#ifndef SERVICE_NOTIFY_RUNNING
#define SERVICE_NOTIFY_RUNNING 0x08
#endif
@Values taken from MSDN documentation
-
Thank you, there are also structs missing. The whole Notify thing is incomplete. My Callback function is called but it seems random, because the status did not change and it happens only on the first run.
Copying the code inside my code does not seem to be right.
Is there an approach in Qt to monitor windows services / linux daemons?
-
Then you should ask on the MinGW forum about the state of this part.
-
Good idea.
ATM I got it partly working. Interestingly it is working but just for the service "hkmsvc". All other method calls return ERROR_INVALID_PARAMETER 87 (0x57). Tomorrow I will test my code in VC2013, maybe this part is a work in progress.
Thanks for your support. ;-)