From f906d0272014390a18b5c0b3e7a2eda0a8bde5cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Sun, 30 Jul 2023 12:38:47 +0800 Subject: [PATCH] Title (Windows): remove the trailing white space of user name on WIndows 7 --- src/util/platform/FFPlatform_windows.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/util/platform/FFPlatform_windows.c b/src/util/platform/FFPlatform_windows.c index faddd9194..13fc97246 100644 --- a/src/util/platform/FFPlatform_windows.c +++ b/src/util/platform/FFPlatform_windows.c @@ -104,31 +104,31 @@ static void getDataDirs(FFPlatform* platform) static void getUserName(FFPlatform* platform) { - ffStrbufEnsureFree(&platform->userName, 64); - DWORD len = (DWORD) ffStrbufGetFree(&platform->userName); - if(GetUserNameA(platform->userName.chars, &len)) - platform->userName.length = (uint32_t) len; + wchar_t buffer[128]; + DWORD len = sizeof(buffer) / sizeof(*buffer); + if(GetUserNameW(buffer, &len)) + ffStrbufSetWS(&platform->userName, buffer); } static void getHostName(FFPlatform* platform) { - ffStrbufEnsureFree(&platform->hostName, 64); - DWORD len = (DWORD) ffStrbufGetFree(&platform->hostName); - if(GetComputerNameExA(ComputerNameDnsHostname, platform->hostName.chars, &len)) - platform->hostName.length = (uint32_t) len; + wchar_t buffer[128]; + DWORD len = sizeof(buffer) / sizeof(*buffer); + if(GetComputerNameExW(ComputerNameDnsHostname, buffer, &len)) + ffStrbufSetWS(&platform->hostName, buffer); } static void getDomainName(FFPlatform* platform) { - ffStrbufEnsureFree(&platform->domainName, 64); - DWORD len = (DWORD) ffStrbufGetFree(&platform->domainName); - if(GetComputerNameExA(ComputerNameDnsDomain, platform->domainName.chars, &len)) - platform->domainName.length = (uint32_t) len; + wchar_t buffer[128]; + DWORD len = sizeof(buffer) / sizeof(*buffer); + if(GetComputerNameExW(ComputerNameDnsDomain, buffer, &len)) + ffStrbufSetWS(&platform->domainName, buffer); } static void getSystemName(FFPlatform* platform) { - ffStrbufAppendS(&platform->systemName, "Windows_NT"); + ffStrbufAppendS(&platform->systemName, getenv("OS")); } static void getSystemReleaseAndVersion(FFPlatform* platform)