diff options
author | Yuhang Zhao <2546789017@qq.com> | 2021-10-24 13:13:12 +0800 |
---|---|---|
committer | Yuhang Zhao <2546789017@qq.com> | 2021-11-02 13:55:15 +0800 |
commit | 2526df506bda99f9497e83a4e6820557a722660e (patch) | |
tree | 48b45a8a8a5cf879b062354a92e02c9303d017f1 /src/corelib | |
parent | 35ddf3498859dc184456346f2b070fe94dabaf26 (diff) |
Remove pre-Win10 code paths in QtBase
Mostly a removal of dynamically loaded API.
They should all exist on Windows 10 1809
(Qt6's minimum supported version).
accessibility parts left untouched to make
sure MinGW still compiles.
Task-number: QTBUG-84432
Pick-to: 6.2
Change-Id: I7a091fc967bd6b9d18ac2de39db16e3b4b9a76ea
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/global/qoperatingsystemversion_win.cpp | 7 | ||||
-rw-r--r-- | src/corelib/io/qlockfile_win.cpp | 17 | ||||
-rw-r--r-- | src/corelib/io/qprocess_win.cpp | 10 | ||||
-rw-r--r-- | src/corelib/io/qstandardpaths_win.cpp | 7 |
4 files changed, 6 insertions, 35 deletions
diff --git a/src/corelib/global/qoperatingsystemversion_win.cpp b/src/corelib/global/qoperatingsystemversion_win.cpp index c514aaf54d..37f2362d0c 100644 --- a/src/corelib/global/qoperatingsystemversion_win.cpp +++ b/src/corelib/global/qoperatingsystemversion_win.cpp @@ -50,10 +50,7 @@ static inline OSVERSIONINFOEX determineWinOsVersion() { OSVERSIONINFOEX result = { sizeof(OSVERSIONINFOEX), 0, 0, 0, 0, {'\0'}, 0, 0, 0, 0, 0}; -#define GetProcAddressA GetProcAddress -#define pGetModuleHandle GetModuleHandleW - - HMODULE ntdll = pGetModuleHandle(L"ntdll.dll"); + HMODULE ntdll = GetModuleHandleW(L"ntdll.dll"); if (Q_UNLIKELY(!ntdll)) return result; @@ -63,7 +60,7 @@ static inline OSVERSIONINFOEX determineWinOsVersion() // because linking to it at load time will not pass the Windows App Certification Kit // https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910.aspx RtlGetVersionFunction pRtlGetVersion = reinterpret_cast<RtlGetVersionFunction>( - reinterpret_cast<QFunctionPointer>(GetProcAddressA(ntdll, "RtlGetVersion"))); + reinterpret_cast<QFunctionPointer>(GetProcAddress(ntdll, "RtlGetVersion"))); if (Q_UNLIKELY(!pRtlGetVersion)) return result; diff --git a/src/corelib/io/qlockfile_win.cpp b/src/corelib/io/qlockfile_win.cpp index 46a6b9da5e..6c0d2c1f8d 100644 --- a/src/corelib/io/qlockfile_win.cpp +++ b/src/corelib/io/qlockfile_win.cpp @@ -42,6 +42,7 @@ #include "private/qlockfile_p.h" #include "private/qfilesystementry_p.h" #include <qt_windows.h> +#include <psapi.h> #include "QtCore/qfileinfo.h" #include "QtCore/qdatetime.h" @@ -131,27 +132,13 @@ bool QLockFilePrivate::isProcessRunning(qint64 pid, const QString &appname) QString QLockFilePrivate::processNameByPid(qint64 pid) { - typedef DWORD (WINAPI *GetModuleFileNameExFunc)(HANDLE, HMODULE, LPTSTR, DWORD); - - HMODULE hPsapi = LoadLibraryA("psapi"); - if (!hPsapi) - return QString(); - GetModuleFileNameExFunc qGetModuleFileNameEx = reinterpret_cast<GetModuleFileNameExFunc>( - reinterpret_cast<QFunctionPointer>(GetProcAddress(hPsapi, "GetModuleFileNameExW"))); - if (!qGetModuleFileNameEx) { - FreeLibrary(hPsapi); - return QString(); - } - HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, DWORD(pid)); if (!hProcess) { - FreeLibrary(hPsapi); return QString(); } wchar_t buf[MAX_PATH]; - const DWORD length = qGetModuleFileNameEx(hProcess, NULL, buf, sizeof(buf) / sizeof(wchar_t)); + const DWORD length = GetModuleFileNameExW(hProcess, NULL, buf, sizeof(buf) / sizeof(wchar_t)); CloseHandle(hProcess); - FreeLibrary(hPsapi); if (!length) return QString(); QString name = QString::fromWCharArray(buf, length); diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index c5dce4d438..c1084d72a1 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -886,14 +886,6 @@ static bool startDetachedUacPrompt(const QString &programIn, const QStringList & const QString &nativeArguments, const QString &workingDir, qint64 *pid) { - typedef BOOL (WINAPI *ShellExecuteExType)(SHELLEXECUTEINFOW *); - - static const ShellExecuteExType shellExecuteEx = // XP ServicePack 1 onwards. - reinterpret_cast<ShellExecuteExType>(QSystemLibrary::resolve(QLatin1String("shell32"), - "ShellExecuteExW")); - if (!shellExecuteEx) - return false; - const QString args = qt_create_commandline(QString(), // needs arguments only arguments, nativeArguments); SHELLEXECUTEINFOW shellExecuteExInfo; @@ -910,7 +902,7 @@ static bool startDetachedUacPrompt(const QString &programIn, const QStringList & shellExecuteExInfo.lpDirectory = reinterpret_cast<LPCWSTR>(workingDir.utf16()); shellExecuteExInfo.nShow = SW_SHOWNORMAL; - if (!shellExecuteEx(&shellExecuteExInfo)) + if (!ShellExecuteExW(&shellExecuteExInfo)) return false; if (pid) *pid = qint64(GetProcessId(shellExecuteExInfo.hProcess)); diff --git a/src/corelib/io/qstandardpaths_win.cpp b/src/corelib/io/qstandardpaths_win.cpp index 60d65f4216..36541a4f81 100644 --- a/src/corelib/io/qstandardpaths_win.cpp +++ b/src/corelib/io/qstandardpaths_win.cpp @@ -179,13 +179,8 @@ static GUID writableSpecialFolderId(QStandardPaths::StandardLocation type) static QString sHGetKnownFolderPath(const GUID &clsid) { QString result; - typedef HRESULT (WINAPI *GetKnownFolderPath)(const GUID&, DWORD, HANDLE, LPWSTR*); - - static const GetKnownFolderPath sHGetKnownFolderPath = // Vista onwards. - reinterpret_cast<GetKnownFolderPath>(QSystemLibrary::resolve(QLatin1String("shell32"), "SHGetKnownFolderPath")); - LPWSTR path; - if (Q_LIKELY(sHGetKnownFolderPath && SUCCEEDED(sHGetKnownFolderPath(clsid, KF_FLAG_DONT_VERIFY, 0, &path)))) { + if (Q_LIKELY(SUCCEEDED(SHGetKnownFolderPath(clsid, KF_FLAG_DONT_VERIFY, 0, &path)))) { result = convertCharArray(path); CoTaskMemFree(path); } |