Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

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

    General and Desktop
    3
    5
    2525
    Loading More Posts
    • 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
      QtFreak last edited by

      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 Reply Quote 0
      • M
        MuldeR last edited by

        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 Reply Quote 0
        • Q
          QtFreak last edited by

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

          Thanks!

          1 Reply Last reply Reply Quote 0
          • M
            MuldeR last edited by

            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 Reply Quote 0
            • C
              ChrisW67 last edited by

              [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 Reply Quote 0
              • First post
                Last post