From 49fc95689da9a574ec0b9c63ac759d35b9da73c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E9=80=9A=E6=B4=B2?= Date: Tue, 13 Jan 2026 10:42:31 +0800 Subject: [PATCH] Platform (Windows): improves hostname retrieval by adding fallback to NetBIOS name --- src/common/impl/FFPlatform_windows.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/common/impl/FFPlatform_windows.c b/src/common/impl/FFPlatform_windows.c index d5b7433e6..cd138dc22 100644 --- a/src/common/impl/FFPlatform_windows.c +++ b/src/common/impl/FFPlatform_windows.c @@ -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)