Browse Source

Make use of Utils::Misc::loadWinAPI

adaptive-webui-19844
Chocobo1 5 years ago
parent
commit
25c56d3b66
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 22
      src/app/qtlocalpeer/qtlocalpeer.cpp

22
src/app/qtlocalpeer/qtlocalpeer.cpp

@ -80,12 +80,7 @@
#include <QLocalServer> #include <QLocalServer>
#include <QLocalSocket> #include <QLocalSocket>
#if defined(Q_OS_WIN) #include "base/utils/misc.h"
#include <QLibrary>
typedef BOOL(WINAPI*PProcessIdToSessionId)(DWORD,DWORD*);
static PProcessIdToSessionId pProcessIdToSessionId = 0;
#endif
namespace QtLP_Private namespace QtLP_Private
{ {
@ -121,17 +116,16 @@ QtLocalPeer::QtLocalPeer(QObject* parent, const QString &appId)
+ QLatin1Char('-') + QString::number(idNum, 16); + QLatin1Char('-') + QString::number(idNum, 16);
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
if (!pProcessIdToSessionId) { using PPROCESSIDTOSESSIONID = BOOL (WINAPI *)(DWORD, DWORD *);
QLibrary lib("kernel32"); const auto processIdToSessionId = Utils::Misc::loadWinAPI<PPROCESSIDTOSESSIONID>("kernel32.dll", "ProcessIdToSessionId");
pProcessIdToSessionId = (PProcessIdToSessionId)lib.resolve("ProcessIdToSessionId");
} if (processIdToSessionId) {
if (pProcessIdToSessionId) {
DWORD sessionId = 0; DWORD sessionId = 0;
pProcessIdToSessionId(GetCurrentProcessId(), &sessionId); processIdToSessionId(GetCurrentProcessId(), &sessionId);
socketName += QLatin1Char('-') + QString::number(sessionId, 16); socketName += (QLatin1Char('-') + QString::number(sessionId, 16));
} }
#else #else
socketName += QLatin1Char('-') + QString::number(::getuid(), 16); socketName += (QLatin1Char('-') + QString::number(::getuid(), 16));
#endif #endif
server = new QLocalServer(this); server = new QLocalServer(this);

Loading…
Cancel
Save