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. Particular WinAPI-function "not declared in this scope" - others work. -Qt5.1
QtWS25 Last Chance

Particular WinAPI-function "not declared in this scope" - others work. -Qt5.1

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 2.7k 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.
  • Q Offline
    Q Offline
    QtFreak
    wrote on last edited by
    #1

    Hey there,
    Since I use a (static) build of Qt 5.1-beta1 I find myself confronted with strange compiler errors. With previous versions, my program compiled and ran just fine; using the current beta, the compiler seems not to recognise the "[url=http://msdn.microsoft.com/en-us/library/windows/desktop/ms724847(v=vs.85).aspx]RegDeleteKeyEx()[/url]" function while creating and modifying keys works.
    Now I stumbled upon a limitation in the header "winreg.h":
    [code]
    #if (WINVER >= 0x0502)
    WINADVAPI LONG WINAPI RegDeleteKeyExA(HKEY,LPCSTR,REGSAM,DWORD);
    WINADVAPI LONG WINAPI RegDeleteKeyExW(HKEY,LPCWSTR,REGSAM,DWORD);
    #endif
    [/code]

    But since I'm using Windows 7 (and since the program worked fine before) this should actually not be a problem!
    So why does the compiler (MinGW with g++ 4.7.2) suddenly ignore this function and how can I fix it?

    Thanks in advance!

    Edit:
    I created a scary workaround by simply commenting the WINVER-checking lines. However, crippling the compiler's headers doesn't seem to be the way to go...

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MuldeR
      wrote on last edited by
      #2

      WINVER is not the Windows version your are building on, but the version you are building for.

      RegDeleteKeyExA() simply wasn't available in Windows versions before Windows Vista, so it's correct to disable it for NT versions smaller than 5.02. Note that "Vista" actually is Windows NT 6.0 (NT 5.2 is WindowsXP x64).

      Normally, there should be a file "targetver.h" in your project, that is included before any Win32 API headers and which defines WINVER as desired. So you should adjust the target Windows version there.

      Or just add this line before any Win32 API includes:
      @//Application will run on Vista or later
      #define WINVER 0x0600@

      My OpenSource software at: http://muldersoft.com/

      Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

      Go visit the coop: http://youtu.be/Jay...

      1 Reply Last reply
      0
      • Q Offline
        Q Offline
        QtFreak
        wrote on last edited by
        #3

        Oh, that clears things up!
        It's just funny that I never had to take care of this before.

        Thanks!

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MuldeR
          wrote on last edited by
          #4

          BTW: If you want to make use of newer Win32 API functions and still make your application work on older Windows versions, like Windows XP, you should have a look at the QLibrary class...

          My OpenSource software at: http://muldersoft.com/

          Qt v4.8.6 MSVC 2013, static/shared: http://goo.gl/BXqhrS

          Go visit the coop: http://youtu.be/Jay...

          1 Reply Last reply
          0
          • C Offline
            C Offline
            ChrisW67
            wrote on last edited by
            #5

            [quote author="QtFreak" date="1369608160"]It's just funny that I never had to take care of this before.[/quote]
            Microsoft's tools hide this for you by defaulting the target version (WINVER) to a version of their choice. That is probably Windows 7 these days although I have not checked. Last time I checked MingW defaults to Windows 98/NT.

            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