Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I must really know which Windows theme my user is using.
More precisely, Classic, XP, Basic or Aero. (Basic theme as in Vista/7 Windows Basic theme)
I already know how to find if it's aero, but how about the others?


The answer can be in any .NET language (C#, VB.NET or C++).


If you really have to know why on Earth I need to know the theme then here you go:
I have some floating buttons over the caption of a form and I need to change their appearance according to the windows theme.
So far I've managed to find Aero/Classic.


Screen shots of the result, after solving the issue: Minimize to tray button

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
376 views
Welcome To Ask or Share your Answers For Others

1 Answer

You can check the registry for the current theme at:

HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionThemes

under String "CurrentTheme" which has the path to the current theme. below is the code for checking it in C#.

using Microsoft.Win32;

public string GetTheme()
{
  string RegistryKey = @"HKEY_CURRENT_USERSoftwareMicrosoftWindowsCurrentVersionThemes";
  string theme;
  theme = (string) Registry.GetValue(RegistryKey, "CurrentTheme", string.Empty);
  theme = theme.Split('\').Last().Split('.').First().ToString();
  return theme;
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...