How to get current Windows theme name?

I'm trying to get the current Windows theme name in C #, but it turned out to be a little tougher than expected. I have a sample code from MSDN:

public void Test()
{
    StringBuilder themeFileName = new StringBuilder(0x200);
    GetCurrentThemeName(themeFileName, themeFileName.Capacity, null, 0, null, 0);
    string fileName = Path.GetFileName(VisualStyleInformation.ThemeFilename);
    if (string.Equals("aero.msstyles", fileName, StringComparison.OrdinalIgnoreCase))
    {
        // user is using aero theme
    }
}

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

GetCurrentTheme () does not modify StringBuilder. I also tried looking at System.Windows.Forms.VisualStyles.VisualStyleInformation, but it is filled with empty values. Does anyone know how to do this? I should be missing out on something easy, but I haven't found anything yet that works.

0
source share
2 answers

This CodeProject article describes how to get "current visual style information" (find this line in an article).

It contains sample code on how to do this.

+3
source

.

-1

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