4

我必须真正知道我的用户正在使用哪个 Windows 主题。
更准确地说,Classic、XP、Basic 或 Aero。(Vista/7 Windows Basic 主题中的基本主题)
我已经知道如何找到它是否是航空的,但是其他的呢?


答案可以是任何 .NET 语言(C#、VB.NET 或 C++)。


如果你真的必须知道为什么我需要知道主题,那么你就去吧:
我在表单的标题上有一些浮动按钮,我需要根据 Windows 主题更改它们的外观。
到目前为止,我已经设法找到 Aero/Classic。


解决问题后的结果截图: 最小化到托盘按钮

4

2 回答 2

4

您可以在以下位置检查当前主题的注册表:

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Themes

在具有当前主题路径的字符串“CurrentTheme”下。下面是在 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;
}
于 2010-12-19T04:47:22.593 回答
3

您可以通过调用IsAppThemed / IsThemeActive检查主题是否处于活动状态,然后通过调用DwmIsCompositionEnabled检查 Aero 。可能还有其他方法可以做到这一点!

编辑

逻辑是:

  1. 我可以导入IsAppThemedIsThemeActive吗?如果不是,那么我必须使用 Windows Classic(Win9x 或 Win2k)。
  2. 返回什么IsAppThemed and IsThemeActive?如果为 false,那么我必须在 Windows Classic 中。
  3. 我可以进口DwmIsCompositionEnabled吗?如果不是,那么我必须以 XP 为主题。
  4. 返回什么DwmIsCompositionEnabled?如果为真,那么我是 Aero,否则我是 Windows Basic。
于 2010-12-18T18:52:01.790 回答