Remove dynamic loading of functions that are present in Windows Vista onwards.
Invoke functions directly and add libraries accordingly. Task-number: QTBUG-51673 Change-Id: Ie19d1fc6aa932d6e93a7d310048e4c162fb81046 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
This commit is contained in:
parent
710ec5caed
commit
4879bc91d4
@ -54,6 +54,8 @@ win32 {
|
|||||||
# Override MinGW's definition in _mingw.h
|
# Override MinGW's definition in _mingw.h
|
||||||
DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
|
DEFINES += WINVER=0x600 _WIN32_WINNT=0x0600
|
||||||
}
|
}
|
||||||
|
|
||||||
|
!winrt: LIBS_PRIVATE += -lwinmm
|
||||||
}
|
}
|
||||||
|
|
||||||
mac|darwin {
|
mac|darwin {
|
||||||
|
@ -47,7 +47,6 @@
|
|||||||
#include "qdatetime.h"
|
#include "qdatetime.h"
|
||||||
#include <private/qlocale_tools_p.h>
|
#include <private/qlocale_tools_p.h>
|
||||||
|
|
||||||
#include <private/qsystemlibrary_p.h>
|
|
||||||
#include <qmutex.h>
|
#include <qmutex.h>
|
||||||
|
|
||||||
#ifndef QT_NO_QOBJECT
|
#ifndef QT_NO_QOBJECT
|
||||||
|
@ -176,8 +176,6 @@ typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACC
|
|||||||
static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
|
static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0;
|
||||||
typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
|
typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD);
|
||||||
static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
|
static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0;
|
||||||
typedef BOOL (WINAPI *PtrGetVolumePathNamesForVolumeNameW)(LPCWSTR,LPWSTR,DWORD,PDWORD);
|
|
||||||
static PtrGetVolumePathNamesForVolumeNameW ptrGetVolumePathNamesForVolumeNameW = 0;
|
|
||||||
QT_END_INCLUDE_NAMESPACE
|
QT_END_INCLUDE_NAMESPACE
|
||||||
|
|
||||||
static TRUSTEE_W currentUserTrusteeW;
|
static TRUSTEE_W currentUserTrusteeW;
|
||||||
@ -272,9 +270,6 @@ static void resolveLibs()
|
|||||||
HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
|
HINSTANCE userenvHnd = QSystemLibrary::load(L"userenv");
|
||||||
if (userenvHnd)
|
if (userenvHnd)
|
||||||
ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
|
ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW");
|
||||||
HINSTANCE kernel32 = LoadLibrary(L"kernel32");
|
|
||||||
if(kernel32)
|
|
||||||
ptrGetVolumePathNamesForVolumeNameW = (PtrGetVolumePathNamesForVolumeNameW)GetProcAddress(kernel32, "GetVolumePathNamesForVolumeNameW");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // QT_NO_LIBRARY
|
#endif // QT_NO_LIBRARY
|
||||||
@ -349,15 +344,13 @@ static QString readSymLink(const QFileSystemEntry &link)
|
|||||||
|
|
||||||
#if !defined(QT_NO_LIBRARY)
|
#if !defined(QT_NO_LIBRARY)
|
||||||
resolveLibs();
|
resolveLibs();
|
||||||
if (ptrGetVolumePathNamesForVolumeNameW) {
|
QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
|
||||||
QRegExp matchVolName(QLatin1String("^Volume\\{([a-z]|[0-9]|-)+\\}\\\\"), Qt::CaseInsensitive);
|
if (matchVolName.indexIn(result) == 0) {
|
||||||
if(matchVolName.indexIn(result) == 0) {
|
DWORD len;
|
||||||
DWORD len;
|
wchar_t buffer[MAX_PATH];
|
||||||
wchar_t buffer[MAX_PATH];
|
QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
|
||||||
QString volumeName = result.mid(0, matchVolName.matchedLength()).prepend(QLatin1String("\\\\?\\"));
|
if (GetVolumePathNamesForVolumeName(reinterpret_cast<LPCWSTR>(volumeName.utf16()), buffer, MAX_PATH, &len) != 0)
|
||||||
if(ptrGetVolumePathNamesForVolumeNameW((wchar_t*)volumeName.utf16(), buffer, MAX_PATH, &len) != 0)
|
result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
|
||||||
result.replace(0,matchVolName.matchedLength(), QString::fromWCharArray(buffer));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif // !Q_OS_WINRT
|
#endif // !Q_OS_WINRT
|
||||||
}
|
}
|
||||||
@ -583,23 +576,14 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry)
|
|||||||
return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
|
return QFileSystemEntry(ret, QFileSystemEntry::FromInternalPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
// FILE_INFO_BY_HANDLE_CLASS has been extended by FileIdInfo = 18 as of VS2012.
|
#if defined(Q_CC_MINGW) && WINVER < 0x0602 // Windows 8 onwards
|
||||||
typedef enum { Q_FileIdInfo = 18 } Q_FILE_INFO_BY_HANDLE_CLASS;
|
|
||||||
|
|
||||||
# if defined(Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
|
|
||||||
|
|
||||||
// MinGW-64 defines FILE_ID_128 as of gcc-4.8.1 along with FILE_SUPPORTS_INTEGRITY_STREAMS
|
|
||||||
# if !(defined(Q_CC_MINGW) && defined(FILE_SUPPORTS_INTEGRITY_STREAMS))
|
|
||||||
typedef struct _FILE_ID_128 {
|
|
||||||
BYTE Identifier[16];
|
|
||||||
} FILE_ID_128, *PFILE_ID_128;
|
|
||||||
# endif // !(Q_CC_MINGW && FILE_SUPPORTS_INTEGRITY_STREAMS)
|
|
||||||
|
|
||||||
typedef struct _FILE_ID_INFO {
|
typedef struct _FILE_ID_INFO {
|
||||||
ULONGLONG VolumeSerialNumber;
|
ULONGLONG VolumeSerialNumber;
|
||||||
FILE_ID_128 FileId;
|
FILE_ID_128 FileId;
|
||||||
} FILE_ID_INFO, *PFILE_ID_INFO;
|
} FILE_ID_INFO, *PFILE_ID_INFO;
|
||||||
# endif // if defined (Q_CC_MINGW) || (defined(Q_CC_MSVC) && (_MSC_VER < 1700 || WINVER <= 0x0601))
|
|
||||||
|
#endif // if defined (Q_CC_MINGW) && WINVER < 0x0602
|
||||||
|
|
||||||
// File ID for Windows up to version 7.
|
// File ID for Windows up to version 7.
|
||||||
static inline QByteArray fileId(HANDLE handle)
|
static inline QByteArray fileId(HANDLE handle)
|
||||||
@ -622,37 +606,21 @@ static inline QByteArray fileId(HANDLE handle)
|
|||||||
// File ID for Windows starting from version 8.
|
// File ID for Windows starting from version 8.
|
||||||
QByteArray fileIdWin8(HANDLE handle)
|
QByteArray fileIdWin8(HANDLE handle)
|
||||||
{
|
{
|
||||||
#ifndef Q_OS_WINRT
|
#if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE)
|
||||||
typedef BOOL (WINAPI* GetFileInformationByHandleExType)(HANDLE, Q_FILE_INFO_BY_HANDLE_CLASS, void *, DWORD);
|
|
||||||
|
|
||||||
// Dynamically resolve GetFileInformationByHandleEx (Vista onwards).
|
|
||||||
static GetFileInformationByHandleExType getFileInformationByHandleEx = 0;
|
|
||||||
if (!getFileInformationByHandleEx) {
|
|
||||||
QSystemLibrary library(QLatin1String("kernel32"));
|
|
||||||
getFileInformationByHandleEx = (GetFileInformationByHandleExType)library.resolve("GetFileInformationByHandleEx");
|
|
||||||
}
|
|
||||||
QByteArray result;
|
|
||||||
if (getFileInformationByHandleEx) {
|
|
||||||
FILE_ID_INFO infoEx;
|
|
||||||
if (getFileInformationByHandleEx(handle, Q_FileIdInfo,
|
|
||||||
&infoEx, sizeof(FILE_ID_INFO))) {
|
|
||||||
result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
|
|
||||||
result += ':';
|
|
||||||
// Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
|
|
||||||
result += QByteArray((char *)&infoEx.FileId, sizeof(infoEx.FileId)).toHex();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else // !Q_OS_WINRT
|
|
||||||
QByteArray result;
|
QByteArray result;
|
||||||
FILE_ID_INFO infoEx;
|
FILE_ID_INFO infoEx;
|
||||||
if (GetFileInformationByHandleEx(handle, FileIdInfo,
|
if (GetFileInformationByHandleEx(handle,
|
||||||
|
static_cast<FILE_INFO_BY_HANDLE_CLASS>(18), // FileIdInfo in Windows 8
|
||||||
&infoEx, sizeof(FILE_ID_INFO))) {
|
&infoEx, sizeof(FILE_ID_INFO))) {
|
||||||
result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
|
result = QByteArray::number(infoEx.VolumeSerialNumber, 16);
|
||||||
result += ':';
|
result += ':';
|
||||||
result += QByteArray((char *)infoEx.FileId.Identifier, sizeof(infoEx.FileId.Identifier)).toHex();
|
// Note: MinGW-64's definition of FILE_ID_128 differs from the MSVC one.
|
||||||
|
result += QByteArray(reinterpret_cast<const char *>(&infoEx.FileId), int(sizeof(infoEx.FileId))).toHex();
|
||||||
}
|
}
|
||||||
#endif // Q_OS_WINRT
|
|
||||||
return result;
|
return result;
|
||||||
|
#else // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
|
||||||
|
return fileId(handle);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//static
|
//static
|
||||||
|
@ -81,7 +81,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#ifdef Q_OS_WIN // for homedirpath reading from registry
|
#ifdef Q_OS_WIN // for homedirpath reading from registry
|
||||||
# include <private/qsystemlibrary_p.h>
|
|
||||||
# include <qt_windows.h>
|
# include <qt_windows.h>
|
||||||
# ifndef Q_OS_WINRT
|
# ifndef Q_OS_WINRT
|
||||||
# include <shlobj.h>
|
# include <shlobj.h>
|
||||||
|
@ -91,35 +91,13 @@ class QEventDispatcherWin32Private;
|
|||||||
#define DWORD_PTR DWORD
|
#define DWORD_PTR DWORD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef MMRESULT(WINAPI *ptimeSetEvent)(UINT, UINT, LPTIMECALLBACK, DWORD_PTR, UINT);
|
|
||||||
typedef MMRESULT(WINAPI *ptimeKillEvent)(UINT);
|
|
||||||
|
|
||||||
static ptimeSetEvent qtimeSetEvent = 0;
|
|
||||||
static ptimeKillEvent qtimeKillEvent = 0;
|
|
||||||
|
|
||||||
LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
|
LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp);
|
||||||
|
|
||||||
static void resolveTimerAPI()
|
|
||||||
{
|
|
||||||
static bool triedResolve = false;
|
|
||||||
if (!triedResolve) {
|
|
||||||
#ifndef QT_NO_THREAD
|
|
||||||
QMutexLocker locker(QMutexPool::globalInstanceGet(&triedResolve));
|
|
||||||
if (triedResolve)
|
|
||||||
return;
|
|
||||||
#endif
|
|
||||||
triedResolve = true;
|
|
||||||
qtimeSetEvent = (ptimeSetEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeSetEvent");
|
|
||||||
qtimeKillEvent = (ptimeKillEvent)QSystemLibrary::resolve(QLatin1String("winmm"), "timeKillEvent");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
|
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
|
||||||
: threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0),
|
: threadId(GetCurrentThreadId()), interrupt(false), closingDown(false), internalHwnd(0),
|
||||||
getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0),
|
getMessageHook(0), serialNumber(0), lastSerialNumber(0), sendPostedEventsWindowsTimerId(0),
|
||||||
wakeUps(0), activateNotifiersPosted(false)
|
wakeUps(0), activateNotifiersPosted(false)
|
||||||
{
|
{
|
||||||
resolveTimerAPI();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QEventDispatcherWin32Private::~QEventDispatcherWin32Private()
|
QEventDispatcherWin32Private::~QEventDispatcherWin32Private()
|
||||||
@ -394,24 +372,27 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
|
|||||||
|
|
||||||
Q_Q(QEventDispatcherWin32);
|
Q_Q(QEventDispatcherWin32);
|
||||||
|
|
||||||
int ok = 0;
|
bool ok = false;
|
||||||
calculateNextTimeout(t, qt_msectime());
|
calculateNextTimeout(t, qt_msectime());
|
||||||
uint interval = t->interval;
|
uint interval = t->interval;
|
||||||
if (interval == 0u) {
|
if (interval == 0u) {
|
||||||
// optimization for single-shot-zero-timer
|
// optimization for single-shot-zero-timer
|
||||||
QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
|
QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
|
||||||
ok = 1;
|
ok = true;
|
||||||
} else if ((interval < 20u || t->timerType == Qt::PreciseTimer) && qtimeSetEvent) {
|
} else if (interval < 20u || t->timerType == Qt::PreciseTimer) {
|
||||||
ok = t->fastTimerId = qtimeSetEvent(interval, 1, qt_fast_timer_proc, (DWORD_PTR)t,
|
// 3/2016: Although MSDN states timeSetEvent() is deprecated, the function
|
||||||
TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
|
// is still deemed to be the most reliable precision timer.
|
||||||
|
t->fastTimerId = timeSetEvent(interval, 1, qt_fast_timer_proc, DWORD_PTR(t),
|
||||||
|
TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS);
|
||||||
|
ok = t->fastTimerId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok == 0) {
|
if (!ok) {
|
||||||
// user normal timers for (Very)CoarseTimers, or if no more multimedia timers available
|
// user normal timers for (Very)CoarseTimers, or if no more multimedia timers available
|
||||||
ok = SetTimer(internalHwnd, t->timerId, interval, 0);
|
ok = SetTimer(internalHwnd, t->timerId, interval, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ok == 0)
|
if (!ok)
|
||||||
qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer");
|
qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -420,7 +401,7 @@ void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t)
|
|||||||
if (t->interval == 0) {
|
if (t->interval == 0) {
|
||||||
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
|
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
|
||||||
} else if (t->fastTimerId != 0) {
|
} else if (t->fastTimerId != 0) {
|
||||||
qtimeKillEvent(t->fastTimerId);
|
timeKillEvent(t->fastTimerId);
|
||||||
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
|
QCoreApplicationPrivate::removePostedTimerEvent(t->dispatcher, t->timerId);
|
||||||
} else if (internalHwnd) {
|
} else if (internalHwnd) {
|
||||||
KillTimer(internalHwnd, t->timerId);
|
KillTimer(internalHwnd, t->timerId);
|
||||||
|
@ -138,7 +138,7 @@ struct WinTimerInfo { // internal timer info
|
|||||||
quint64 timeout; // - when to actually fire
|
quint64 timeout; // - when to actually fire
|
||||||
QObject *obj; // - object to receive events
|
QObject *obj; // - object to receive events
|
||||||
bool inTimerEvent;
|
bool inTimerEvent;
|
||||||
int fastTimerId;
|
UINT fastTimerId;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QZeroTimerEvent : public QTimerEvent
|
class QZeroTimerEvent : public QTimerEvent
|
||||||
|
@ -62,7 +62,6 @@
|
|||||||
#include "qvariant.h"
|
#include "qvariant.h"
|
||||||
#include "qstringbuilder.h"
|
#include "qstringbuilder.h"
|
||||||
#include "private/qnumeric_p.h"
|
#include "private/qnumeric_p.h"
|
||||||
#include "private/qsystemlibrary_p.h"
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# include <qt_windows.h>
|
# include <qt_windows.h>
|
||||||
# include <time.h>
|
# include <time.h>
|
||||||
|
@ -44,9 +44,6 @@
|
|||||||
#include "qstringlist.h"
|
#include "qstringlist.h"
|
||||||
#include "qvariant.h"
|
#include "qvariant.h"
|
||||||
#include "qdatetime.h"
|
#include "qdatetime.h"
|
||||||
|
|
||||||
#include "private/qsystemlibrary_p.h"
|
|
||||||
|
|
||||||
#include "qdebug.h"
|
#include "qdebug.h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
@ -67,7 +64,6 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT);
|
static QByteArray getWinLocaleName(LCID id = LOCALE_USER_DEFAULT);
|
||||||
static const char *winLangCodeToIsoName(int code);
|
|
||||||
static QString winIso639LangName(LCID id = LOCALE_USER_DEFAULT);
|
static QString winIso639LangName(LCID id = LOCALE_USER_DEFAULT);
|
||||||
static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT);
|
static QString winIso3116CtryName(LCID id = LOCALE_USER_DEFAULT);
|
||||||
#else // !Q_OS_WINRT
|
#else // !Q_OS_WINRT
|
||||||
@ -600,50 +596,32 @@ QVariant QSystemLocalePrivate::toCurrencyString(const QSystemLocale::CurrencyToS
|
|||||||
|
|
||||||
QVariant QSystemLocalePrivate::uiLanguages()
|
QVariant QSystemLocalePrivate::uiLanguages()
|
||||||
{
|
{
|
||||||
if (QSysInfo::windowsVersion() >= QSysInfo::WV_VISTA) {
|
|
||||||
typedef BOOL (WINAPI *GetUserPreferredUILanguagesFunc) (
|
|
||||||
DWORD dwFlags,
|
|
||||||
PULONG pulNumLanguages,
|
|
||||||
PWSTR pwszLanguagesBuffer,
|
|
||||||
PULONG pcchLanguagesBuffer);
|
|
||||||
static GetUserPreferredUILanguagesFunc GetUserPreferredUILanguages_ptr = 0;
|
|
||||||
#ifndef Q_OS_WINRT
|
#ifndef Q_OS_WINRT
|
||||||
if (!GetUserPreferredUILanguages_ptr) {
|
unsigned long cnt = 0;
|
||||||
QSystemLibrary lib(QLatin1String("kernel32"));
|
QVarLengthArray<wchar_t, 64> buf(64);
|
||||||
if (lib.load())
|
# if !defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE) // Not present in MinGW 4.9/bootstrap builds.
|
||||||
GetUserPreferredUILanguages_ptr = (GetUserPreferredUILanguagesFunc)lib.resolve("GetUserPreferredUILanguages");
|
unsigned long size = buf.size();
|
||||||
}
|
if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
|
||||||
#endif // !Q_OS_WINRT
|
size = 0;
|
||||||
if (GetUserPreferredUILanguages_ptr) {
|
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
|
||||||
unsigned long cnt = 0;
|
GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
|
||||||
QVarLengthArray<wchar_t, 64> buf(64);
|
buf.resize(size);
|
||||||
unsigned long size = buf.size();
|
if (!GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
|
||||||
if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size)) {
|
return QStringList();
|
||||||
size = 0;
|
|
||||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER &&
|
|
||||||
GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, NULL, &size)) {
|
|
||||||
buf.resize(size);
|
|
||||||
if (!GetUserPreferredUILanguages_ptr(MUI_LANGUAGE_NAME, &cnt, buf.data(), &size))
|
|
||||||
return QStringList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
QStringList result;
|
|
||||||
result.reserve(cnt);
|
|
||||||
const wchar_t *str = buf.constData();
|
|
||||||
for (; cnt > 0; --cnt) {
|
|
||||||
QString s = QString::fromWCharArray(str);
|
|
||||||
if (s.isEmpty())
|
|
||||||
break; // something is wrong
|
|
||||||
result.append(s);
|
|
||||||
str += s.size()+1;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
# endif // !QT_BOOTSTRAPPED && !QT_BUILD_QMAKE
|
||||||
#ifndef Q_OS_WINRT
|
QStringList result;
|
||||||
// old Windows before Vista
|
result.reserve(cnt);
|
||||||
return QStringList(QString::fromLatin1(winLangCodeToIsoName(GetUserDefaultUILanguage())));
|
const wchar_t *str = buf.constData();
|
||||||
|
for (; cnt > 0; --cnt) {
|
||||||
|
QString s = QString::fromWCharArray(str);
|
||||||
|
if (s.isEmpty())
|
||||||
|
break; // something is wrong
|
||||||
|
result.append(s);
|
||||||
|
str += s.size() + 1;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
#else // !Q_OS_WINRT
|
#else // !Q_OS_WINRT
|
||||||
QStringList result;
|
QStringList result;
|
||||||
ComPtr<ABI::Windows::Globalization::IApplicationLanguagesStatics> appLanguagesStatics;
|
ComPtr<ABI::Windows::Globalization::IApplicationLanguagesStatics> appLanguagesStatics;
|
||||||
|
Loading…
Reference in New Issue
Block a user