From e52a8fb0b034e73516335f99a0cd875140a7ef5a Mon Sep 17 00:00:00 2001 From: "Vladimir Golovnev (Glassez)" Date: Tue, 20 Jan 2015 17:54:41 +0300 Subject: [PATCH] Fix misc::getUserIDString() on Windows. Return current user name now (and not constant "0"). Also use Unicode version of GetUserName(). --- src/core/misc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/misc.cpp b/src/core/misc.cpp index c11b68636..16995e322 100644 --- a/src/core/misc.cpp +++ b/src/core/misc.cpp @@ -444,10 +444,10 @@ QString misc::getUserIDString() { QString uid = "0"; #ifdef Q_OS_WIN - char buffer[UNLEN + 1] = {0}; - DWORD buffer_len = UNLEN + 1; - if (!GetUserNameA(buffer, &buffer_len)) - uid = QString(buffer); + WCHAR buffer[UNLEN + 1] = {0}; + DWORD buffer_len = sizeof(buffer)/sizeof(*buffer); + if (GetUserNameW(buffer, &buffer_len)) + uid = QString::fromWCharArray(buffer); #else uid = QString::number(getuid()); #endif