mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2025-03-29 16:42:38 +08:00
Reverted GetUserName API usage on Windows (#25)
* Added back support for getting username on Windows * Fixed typo in singleapplication.pri * Compiler specific Advapi32.lib links * Removed username debug statement
This commit is contained in:
parent
1c5164ed10
commit
4841681918
@ -37,6 +37,11 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include <windows.h>
|
||||||
|
#include <lmcons.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "singleapplication.h"
|
#include "singleapplication.h"
|
||||||
#include "singleapplication_p.h"
|
#include "singleapplication_p.h"
|
||||||
|
|
||||||
@ -85,7 +90,15 @@ void SingleApplicationPrivate::genBlockServerName( int timeout )
|
|||||||
// User level block requires a user specific data in the hash
|
// User level block requires a user specific data in the hash
|
||||||
if( options & SingleApplication::Mode::User ) {
|
if( options & SingleApplication::Mode::User ) {
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() );
|
Q_UNUSED(timeout);
|
||||||
|
wchar_t username [ UNLEN + 1 ];
|
||||||
|
// Specifies size of the buffer on input
|
||||||
|
DWORD usernameLength = UNLEN + 1;
|
||||||
|
if( GetUserName( username, &usernameLength ) ) {
|
||||||
|
appData.addData( QString::fromWCharArray(username).toUtf8() );
|
||||||
|
} else {
|
||||||
|
appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() );
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
@ -6,3 +6,8 @@ HEADERS += $$PWD/singleapplication.h \
|
|||||||
SOURCES += $$PWD/singleapplication.cpp
|
SOURCES += $$PWD/singleapplication.cpp
|
||||||
|
|
||||||
INCLUDEPATH += $$PWD
|
INCLUDEPATH += $$PWD
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
msvc:LIBS += Advapi32.lib
|
||||||
|
gcc:LIBS += -lAdvapi32
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user