I am trying to get the current Windows theme name in C# but it has turned out to be a little tougher than expected. I have a code sample 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 the StringBuilder. I also tried looking at the
System.Windows.Forms.VisualStyles.VisualStyleInformation class, but it is full of empty values. Anyone know how to do this? I must be missing something easy, but I haven’t found anything yet that works.
That article on CodeProject describes how to get ‘the current visual style information’ (search for that string in the article).
It contains sample code how to do that.