Platform: retrieve full user name

This commit is contained in:
李通洲
2025-04-09 14:58:36 +08:00
committed by 李通洲
parent fc31fe4aa4
commit 3c291f1af9
6 changed files with 17 additions and 1 deletions
+1
View File
@@ -12,6 +12,7 @@ void ffPlatformInit(FFPlatform* platform)
ffStrbufInit(&platform->exePath);
ffStrbufInit(&platform->userName);
ffStrbufInit(&platform->fullUserName);
ffStrbufInit(&platform->hostName);
ffStrbufInit(&platform->userShell);
+1
View File
@@ -22,6 +22,7 @@ typedef struct FFPlatform
FFstrbuf exePath; // The real path of current exe
FFstrbuf userName;
FFstrbuf fullUserName;
FFstrbuf hostName;
FFstrbuf userShell;
+2
View File
@@ -181,6 +181,8 @@ static void getUserName(FFPlatform* platform, const struct passwd* pwd)
user = pwd->pw_name;
ffStrbufAppendS(&platform->userName, user);
if (pwd) ffStrbufAppendS(&platform->fullUserName, pwd->pw_gecos);
}
static void getHostName(FFPlatform* platform, const struct utsname* uts)
+9 -1
View File
@@ -9,6 +9,9 @@
#include <Windows.h>
#include <shlobj.h>
#define SECURITY_WIN32 1 // For secext.h
#include <secext.h>
static void getExePath(FFPlatform* platform)
{
wchar_t exePathW[MAX_PATH];
@@ -138,11 +141,16 @@ static void getUserName(FFPlatform* platform)
ffStrbufSetS(&platform->userName, userName);
else
{
wchar_t buffer[128];
wchar_t buffer[256];
DWORD len = ARRAY_SIZE(buffer);
if(GetUserNameW(buffer, &len))
ffStrbufSetWS(&platform->userName, buffer);
}
wchar_t buffer[256];
DWORD len = ARRAY_SIZE(buffer);
if (GetUserNameExW(NameDisplay, buffer, &len))
ffStrbufSetWS(&platform->fullUserName, buffer);
}
static void getHostName(FFPlatform* platform)