UI: ControlManager: Named pipe name is per user name.

This commit is contained in:
Nodir Temirkhodjaev 2021-08-08 16:17:21 +03:00
parent 4000db08b8
commit 4760547083
3 changed files with 14 additions and 1 deletions

View File

@ -210,5 +210,5 @@ void ControlManager::close()
QString ControlManager::getServerName(bool isService) QString ControlManager::getServerName(bool isService)
{ {
return QLatin1String(APP_BASE) + (isService ? "Svc" : QString()) + "Pipe"; return QLatin1String(APP_BASE) + (isService ? "Svc" : OsUtil::userName()) + "Pipe";
} }

View File

@ -10,6 +10,8 @@
#define WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN
#include <qt_windows.h> #include <qt_windows.h>
#include <lmcons.h>
#include "processinfo.h" #include "processinfo.h"
namespace { namespace {
@ -97,6 +99,16 @@ qint32 OsUtil::getTickCount()
return qint32(GetTickCount()); return qint32(GetTickCount());
} }
QString OsUtil::userName()
{
wchar_t buf[UNLEN + 1];
DWORD len = UNLEN + 1;
if (GetUserNameW(buf, &len)) {
return QString::fromWCharArray(buf, int(len) - 1); // skip terminationg null char.
}
return QString();
}
bool OsUtil::isUserAdmin() bool OsUtil::isUserAdmin()
{ {
SID_IDENTIFIER_AUTHORITY idAuth = SECURITY_NT_AUTHORITY; SID_IDENTIFIER_AUTHORITY idAuth = SECURITY_NT_AUTHORITY;

View File

@ -30,6 +30,7 @@ public:
static qint32 getTickCount(); static qint32 getTickCount();
static QString userName();
static bool isUserAdmin(); static bool isUserAdmin();
static bool beep(BeepType type = BeepSimple); static bool beep(BeepType type = BeepSimple);