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))
{
}
}
[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.
source
share