@@ -4648,6 +4648,48 @@ void UpgradeSettings( bool bShared )
4648
4648
}
4649
4649
}
4650
4650
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
+
4651
4693
void UpdateSettings ( void )
4652
4694
{
4653
4695
{
@@ -4770,16 +4812,10 @@ void UpdateSettings( void )
4770
4812
4771
4813
UpdateSetting (L" NumericSort" ,CComVariant (SHRestricted (REST_NOSTRCMPLOGICAL)?0 :1 ),false );
4772
4814
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 );
4781
4816
4782
- size=_countof (title);
4817
+ wchar_t title[256 ]{};
4818
+ ULONG size=_countof (title);
4783
4819
if (!GetUserNameEx (NameDisplay,title,&size))
4784
4820
{
4785
4821
// GetUserNameEx may fail (for example on Home editions). use the login name
0 commit comments