Get Windows theme?

不打扰是莪最后的温柔 提交于 2019-11-28 12:50:34

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:

  1. Can I import IsAppThemed and IsThemeActive? If no then I must be in Windows Classic (Win9x or Win2k).
  2. What does IsAppThemed and IsThemeActive return? If false then I must be in Windows Classic.
  3. Can I import DwmIsCompositionEnabled? If no then I must be XP themed.
  4. What does DwmIsCompositionEnabled return? If true then I am Aero, otherwise I am Windows Basic.

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;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!