Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get NotifyServiceStatusChange into Qt?

How to get NotifyServiceStatusChange into Qt?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 3.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    syfy323
    wrote on last edited by
    #1

    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-service

    Is it possible to use NotifyServiceStatusChange with Qt?
    Thanks.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      NotifyServiceStatusChange is only available since Windows Vista. See "here":http://msdn.microsoft.com/en-us/library/windows/desktop/ms684276(v=vs.85).aspx

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • S Offline
        S Offline
        syfy323
        wrote on last edited by
        #3

        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)/@

        1 Reply Last reply
        0
        • S Offline
          S Offline
          syfy323
          wrote on last edited by
          #4

          @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.

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            It's one way to do it yes, or you can define WINVER before including qt_windows.h in your code

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • S Offline
              S Offline
              syfy323
              wrote on last edited by
              #6

              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?

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  syfy323
                  wrote on last edited by
                  #8

                  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?

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    Then you should ask on the MinGW forum about the state of this part.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      syfy323
                      wrote on last edited by
                      #10

                      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. ;-)

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved