Call Windows API directly

We already bumped the OS requirement to Windows 7 and those functions
can be called directly without the need to load them first.
This commit is contained in:
Chocobo1
2019-09-28 15:46:26 +08:00
parent 975b44d05f
commit 7276a79cef
5 changed files with 15 additions and 39 deletions

View File

@@ -116,14 +116,9 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
+ QLatin1Char('-') + QString::number(idNum, 16);
#if defined(Q_OS_WIN)
using PPROCESSIDTOSESSIONID = BOOL (WINAPI *)(DWORD, DWORD *);
const auto processIdToSessionId = Utils::Misc::loadWinAPI<PPROCESSIDTOSESSIONID>("kernel32.dll", "ProcessIdToSessionId");
if (processIdToSessionId) {
DWORD sessionId = 0;
processIdToSessionId(GetCurrentProcessId(), &sessionId);
socketName += (QLatin1Char('-') + QString::number(sessionId, 16));
}
DWORD sessionId = 0;
::ProcessIdToSessionId(GetCurrentProcessId(), &sessionId);
socketName += (QLatin1Char('-') + QString::number(sessionId, 16));
#else
socketName += (QLatin1Char('-') + QString::number(::getuid(), 16));
#endif