/* This file is part of the KDE project SPDX-FileCopyrightText: 1999 David Faure SPDX-FileCopyrightText: 2014 Alex Richardson SPDX-License-Identifier: LGPL-2.0-or-later */ #ifndef SYSTEMINFORMATION_P_H #define SYSTEMINFORMATION_P_H #include namespace SystemInformation { QString userName(); } #if !defined(Q_OS_WIN) #include #include #include inline QString SystemInformation::userName() { struct passwd *p = getpwuid(getuid()); return QString::fromLatin1(p->pw_name); } #else #include #include #define SECURITY_WIN32 #include //#include // GetUserNameEx inline QString SystemInformation::userName() { WCHAR nameBuffer[256]; DWORD bufsize = 256; if (!GetUserNameExW(NameDisplay, nameBuffer, &bufsize)) { return QStringLiteral("Unknown User"); // should never happen (translate?) } return QString::fromWCharArray(nameBuffer); } #endif #endif // SYSTEMINFORMATION_P_H