private static void EnsureThemeName() { StringBuilder themeName = new StringBuilder(Win32.NativeMethods.MAX_PATH); StringBuilder themeColor = new StringBuilder(Win32.NativeMethods.MAX_PATH); if (UnsafeNativeMethods.GetCurrentThemeName(themeName, themeName.Capacity, themeColor, themeColor.Capacity, null, 0) == 0) { // Success _themeName = themeName.ToString(); _themeName = Path.GetFileNameWithoutExtension(_themeName); if (String.Compare(_themeName, "aero", StringComparison.OrdinalIgnoreCase) == 0 && Utilities.IsOSWindows8OrNewer) { _themeName = "Aero2"; } _themeColor = themeColor.ToString(); } else { // Failed to retrieve the name _themeName = _themeColor = String.Empty; } }
private static void GetThemeNameAndColor(out string themeName, out string themeColor) { StringBuilder themeNameSB = new StringBuilder(Win32.NativeMethods.MAX_PATH); StringBuilder themeColorSB = new StringBuilder(Win32.NativeMethods.MAX_PATH); if (UnsafeNativeMethods.GetCurrentThemeName(themeNameSB, themeNameSB.Capacity, themeColorSB, themeColorSB.Capacity, null, 0) == 0) { // Success themeName = themeNameSB.ToString(); themeName = Path.GetFileNameWithoutExtension(themeName); if (String.Compare(themeName, "aero", StringComparison.OrdinalIgnoreCase) == 0 && Utilities.IsOSWindows8OrNewer) { themeName = "Aero2"; } #if DEBUG // for debugging, config file can override the theme name NameValueCollection appSettings = null; try { appSettings = ConfigurationManager.AppSettings; } catch (ConfigurationErrorsException) { } if (appSettings != null) { string s = appSettings["ThemeNameOverride"]; if (!String.IsNullOrEmpty(s)) { themeName = s; } } #endif themeColor = themeColorSB.ToString(); } else { // Failed to retrieve the name themeName = themeColor = String.Empty; } }
private static void GetThemeNameAndColor(out string themeName, out string themeColor) { StringBuilder stringBuilder = new StringBuilder(260); StringBuilder stringBuilder2 = new StringBuilder(260); if (UnsafeNativeMethods.GetCurrentThemeName(stringBuilder, stringBuilder.Capacity, stringBuilder2, stringBuilder2.Capacity, null, 0) == 0) { themeName = stringBuilder.ToString(); themeName = Path.GetFileNameWithoutExtension(themeName); if (string.Compare(themeName, "aero", StringComparison.OrdinalIgnoreCase) == 0 && Utilities.IsOSWindows8OrNewer) { themeName = "Aero2"; } themeColor = stringBuilder2.ToString(); return; } string empty; themeColor = (empty = string.Empty); themeName = empty; }