mirror of
https://github.com/itay-grudev/SingleApplication.git
synced 2025-01-15 17:02:06 +08:00
Fix bug (and compiler error) on Windows - wchar username support
This commit is contained in:
parent
5f0c8a3316
commit
5d867d77a5
@ -68,12 +68,13 @@ void SingleApplicationPrivate::genBlockServerName( int timeout )
|
||||
// User level block requires a user specific data in the hash
|
||||
if( options & SingleApplication::Mode::User ) {
|
||||
#ifdef Q_OS_WIN
|
||||
char username[UNLEN + 1];
|
||||
wchar_t username [ UNLEN + 1 ];
|
||||
// Specifies size of the buffer on input
|
||||
DWORD usernameLength = sizeof( username );
|
||||
DWORD usernameLength = UNLEN + 1;
|
||||
if( GetUserName( username, &usernameLength ) ) {
|
||||
// usernameLength includes the null terminating character
|
||||
appData.addData( username, usernameLength - 1 );
|
||||
char buffer[512];
|
||||
size_t length = wcstombs( buffer, username, 512 );
|
||||
appData.addData( buffer, length );
|
||||
} else {
|
||||
appData.addData( QStandardPaths::standardLocations( QStandardPaths::HomeLocation ).join("").toUtf8() );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user