Skip to content

Commit 7f6b722

Browse files
committed
1 parent a0a0376 commit 7f6b722

File tree

1 file changed

+45
-9
lines changed

1 file changed

+45
-9
lines changed

Src/StartMenu/StartMenuDLL/SettingsUI.cpp

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4648,6 +4648,48 @@ void UpgradeSettings( bool bShared )
46484648
}
46494649
}
46504650

4651+
static CString GetWindowsBrandingString()
4652+
{
4653+
CString retval;
4654+
4655+
if (GetWinVersion() >= WIN_VER_WIN10)
4656+
{
4657+
auto winbrand = LoadLibraryEx(L"winbrand.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
4658+
if (winbrand)
4659+
{
4660+
PWSTR (WINAPI * BrandingFormatString)(PCWSTR pstrFormat);
4661+
BrandingFormatString = (decltype(BrandingFormatString))GetProcAddress(winbrand, "BrandingFormatString");
4662+
if (BrandingFormatString)
4663+
{
4664+
auto osName = BrandingFormatString(L"%WINDOWS_LONG%");
4665+
if (osName)
4666+
{
4667+
retval = osName;
4668+
GlobalFree(osName);
4669+
}
4670+
}
4671+
4672+
FreeLibrary(winbrand);
4673+
}
4674+
}
4675+
4676+
if (retval.IsEmpty())
4677+
{
4678+
// fallback for older Windows
4679+
wchar_t title[256] = L"Windows";
4680+
4681+
if (CRegKey reg; reg.Open(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion", KEY_READ) == ERROR_SUCCESS)
4682+
{
4683+
ULONG size = _countof(title);
4684+
reg.QueryStringValue(L"ProductName", title, &size);
4685+
}
4686+
4687+
retval = title;
4688+
}
4689+
4690+
return retval;
4691+
}
4692+
46514693
void UpdateSettings( void )
46524694
{
46534695
{
@@ -4770,16 +4812,10 @@ void UpdateSettings( void )
47704812

47714813
UpdateSetting(L"NumericSort",CComVariant(SHRestricted(REST_NOSTRCMPLOGICAL)?0:1),false);
47724814

4773-
wchar_t title[256]=L"Windows";
4774-
ULONG size=_countof(title);
4775-
{
4776-
CRegKey regTitle;
4777-
if (regTitle.Open(HKEY_LOCAL_MACHINE,L"Software\\Microsoft\\Windows NT\\CurrentVersion",KEY_READ)==ERROR_SUCCESS)
4778-
regTitle.QueryStringValue(L"ProductName",title,&size);
4779-
}
4780-
UpdateSetting(L"MenuCaption",CComVariant(title),false);
4815+
UpdateSetting(L"MenuCaption",CComVariant(GetWindowsBrandingString()),false);
47814816

4782-
size=_countof(title);
4817+
wchar_t title[256]{};
4818+
ULONG size=_countof(title);
47834819
if (!GetUserNameEx(NameDisplay,title,&size))
47844820
{
47854821
// GetUserNameEx may fail (for example on Home editions). use the login name

0 commit comments

Comments
 (0)