How can I find out which window theme I am using?

I am trying to get the application to apply the theme - it is straightforward, as shown here: http://arbel.net/blog/archive/2006/11/03/Forcing-WPF-to-use-a-specific-Windows-theme.aspx

However, I do not know what topic I am using now. I use the default Windows XP theme, whatever that is. This article says:

It is important to specify the version and public key token

... where can I get this information?

+3
source share
1 answer

To get the theme name, you can call the unmanaged GetCurrentThemeName method:

public string GetThemeName()
{
  StringBuilder themeNameBuffer = new StringBuilder(260);
  var error = GetCurrentThemeName(themeNameBuffer, themeNameBuffer.Capacity, null, 0, null, 0);
  if(error!=0) Marshal.ThrowExceptionForHR(error);
  return themeNameBuffer.ToString();
}

[DllImport("uxtheme.dll", CharSet=CharSet.Auto)]
public static extern int GetCurrentThemeName(StringBuilder pszThemeFileName, int dwMaxNameChars, StringBuilder pszColorBuff, int dwMaxColorChars, StringBuilder pszSizeBuff, int cchMaxSizeChars);

, .dll(, PresentationFramework.Aero) GAC ( c:\Windows\Assembly in Exporer), , , AppDomain.CurrentDomain.LoadedAssemblies , :

foreach(Assembly a in AppDomain.CurrentDomain.LoadedAssemblies)
  if(a.Name.StartsWith("PresentationFramework."))
    return a.FullName;

, , AppDomain .

+4

Source: https://habr.com/ru/post/1748589/


All Articles