Particular WinAPI-function "not declared in this scope" - others work. -Qt5.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... -
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@ -
[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.