Reputation: 9141
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:
Upvotes: 4
Views: 8784
Reputation: 18430
You can check the registry for the current theme at:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes
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_USER\Software\Microsoft\Windows\CurrentVersion\Themes";
string theme;
theme = (string) Registry.GetValue(RegistryKey, "CurrentTheme", string.Empty);
theme = theme.Split('\\').Last().Split('.').First().ToString();
return theme;
}
Upvotes: 5
Reputation: 612954
You can check whether themes are active by calling IsAppThemed/IsThemeActive and then check for Aero by calling DwmIsCompositionEnabled. There may well be other ways of doing this!!
EDIT
The logic would be:
IsAppThemed
and IsThemeActive
? If no then I must be in Windows Classic (Win9x or Win2k).IsAppThemed and IsThemeActive
return? If false then I must be in Windows Classic.DwmIsCompositionEnabled
? If no then I must be XP themed.DwmIsCompositionEnabled
return? If true then I am Aero, otherwise I am Windows Basic.Upvotes: 3