mirror of
https://github.com/fastfetch-cli/fastfetch.git
synced 2026-09-13 02:42:09 +02:00
OS (Windows): acquires OS name from registry
This commit is contained in:
@@ -69,6 +69,17 @@ void ffDetectOSImpl(FFOSResult* os)
|
||||
if(ffStrbufStartsWithS(&os->variant, "Microsoft "))
|
||||
ffStrbufSubstrAfter(&os->variant, strlen("Microsoft ") - 1);
|
||||
|
||||
if(os->variant.length == 0) // Windows PE?
|
||||
{
|
||||
wchar_t buf[128];
|
||||
DWORD bufSize = (DWORD) sizeof(buf); // with trailing '\0'
|
||||
if(RegGetValueW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", L"ProductName", RRF_RT_REG_SZ, NULL, buf, &bufSize) == ERROR_SUCCESS)
|
||||
{
|
||||
assert(bufSize >= sizeof(wchar_t));
|
||||
ffStrbufSetNWS(&os->variant, bufSize / sizeof(wchar_t) - 1, buf);
|
||||
}
|
||||
}
|
||||
|
||||
ffStrbufSet(&os->prettyName, &os->variant);
|
||||
|
||||
if(ffStrbufStartsWithS(&os->variant, "Windows "))
|
||||
@@ -83,6 +94,9 @@ void ffDetectOSImpl(FFOSResult* os)
|
||||
ffStrbufSubstrAfter(&os->variant, strlen(" Server") - 1);
|
||||
}
|
||||
|
||||
if(ffStrbufStartsWithIgnCaseS(&os->variant, "(TM) "))
|
||||
ffStrbufSubstrAfter(&os->variant, strlen(" (TM)") - 1);
|
||||
|
||||
uint32_t index = ffStrbufFirstIndexC(&os->variant, ' ');
|
||||
ffStrbufAppendNS(&os->version, index, os->variant.chars);
|
||||
ffStrbufSubstrAfter(&os->variant, index);
|
||||
|
||||
Reference in New Issue
Block a user