Platform (Windows): improves hostname retrieval by adding fallback to NetBIOS name

This commit is contained in:
李通洲
2026-01-13 10:42:31 +08:00
parent 3d84ad19be
commit 49fc95689d
+9 -3
View File
@@ -155,10 +155,16 @@ static void getUserName(FFPlatform* platform)
static void getHostName(FFPlatform* platform)
{
wchar_t buffer[128];
wchar_t buffer[256];
DWORD len = ARRAY_SIZE(buffer);
if(GetComputerNameExW(ComputerNameDnsHostname, buffer, &len))
ffStrbufSetWS(&platform->hostName, buffer);
if (GetComputerNameExW(ComputerNameDnsHostname, buffer, &len) && len > 0)
ffStrbufSetNWS(&platform->hostName, len, buffer);
else
{
len = ARRAY_SIZE(buffer);
if (GetComputerNameExW(ComputerNameNetBIOS, buffer, &len) && len > 0)
ffStrbufSetNWS(&platform->hostName, len, buffer);
}
}
static void getUserShell(FFPlatform* platform)