0

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.

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

You are not passing the string builder by reference.

2 Comments

Well, the reference is passed by value. i did not think that the function would change the referenced object. I will try that when i get a chance, thanks.
This is a comment, not an answer.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.