summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorYuhang Zhao <2546789017@qq.com>2021-10-24 13:13:12 +0800
committerYuhang Zhao <2546789017@qq.com>2021-11-02 13:55:15 +0800
commit2526df506bda99f9497e83a4e6820557a722660e (patch)
tree48b45a8a8a5cf879b062354a92e02c9303d017f1 /src/corelib/io
parent35ddf3498859dc184456346f2b070fe94dabaf26 (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/io')
-rw-r--r--src/corelib/io/qlockfile_win.cpp17
-rw-r--r--src/corelib/io/qprocess_win.cpp10
-rw-r--r--src/corelib/io/qstandardpaths_win.cpp7
3 files changed, 4 insertions, 30 deletions
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);
}