GetFileSizeEx was not declared in this scope
Hi,
I use GetFileSizeEx since it seems to work faster than working with QFileInfo.
Now I wanted to use it inside a new class I added, and QT creator tells me "GetFileSizeEx was not declared in this scope".
I copied ALL header Files that are included in the class that works fine, but the problem still consist.
Other function calls like FindFirstFileW and CreateFileW wont raise an error.
Qt Creator even shows me the prototype of the function in a Tooltip "BOOL GetFileSizeEx(HANDLE, PLARGE_INTEGER)"
What am i doing wrong?
Re: GetFileSizeEx was not declared in this scope
From <winbase.h>:
Code:
#if (_WIN32_WINNT >= 0x0500)
WINBASEAPI BOOL WINAPI GetFileSizeEx(HANDLE,PLARGE_INTEGER);
#endif
Check which headers were included before <winbase.h> or <windows.h> when GetFileSizeEx was working, one of them could modify the _WIN32_WINNT define.
According to this article you can do that yourself, just put this in your .cpp file ( the one where you are trying to call GetFileSizeEx ):
Code:
// 0x0501 is for Windows XP ( no service pack ),
// values for other configurations are listed in the article
#define _WIN32_WINNT 0x0501
#include <windows.h>
Re: GetFileSizeEx was not declared in this scope
@stampede: You made my day :)
The order of the header files did the trick!
Works fine:
Code:
#include <QObject>
#include <QString>
#include <QStringList>
#include <qt_windows.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
Throws ... not declared Error:
Code:
#include <qt_windows.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <QObject>
#include <QString>
#include <QStringList>
I have never experienced such a strange behavior before.
Problem solved, thanks again!