65.9K
CodeProject 正在变化。 阅读更多。
Home

在 Windows Vista 和 7 上启用和禁用 Aero 界面

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.14/5 (11投票s)

2009年8月29日

CPOL
viewsIcon

39803

downloadIcon

493

Aero 导致您的应用程序不稳定吗?快来看看吧...

介绍 

您的应用程序与 Aero 界面不兼容吗?您想从您的应用程序中禁用 Aero 吗?您来对地方了。

Using the Code

使用这段代码非常简单,几乎任何人都可以轻松使用它。

只需将 System.Runtime.InteropServices 添加到您的引用中,并将此代码粘贴到应用程序中即可。

public readonly uint DWM_EC_DISABLECOMPOSITION = 0;
public readonly uint DWM_EC_ENABLECOMPOSITION = 1;
[DllImport("dwmapi.dll", EntryPoint = "DwmEnableComposition")]
protected extern static uint Win32DwmEnableComposition(uint uCompositionAction);
public bool ControlAero(bool enable)
{
  try
  {
    if (enable)
      Win32DwmEnableComposition(DWM_EC_ENABLECOMPOSITION);
    if (!enable)
      Win32DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);

    return true;  
  }
  catch { return false; }
}

您可以使用 ControlAero(false) 禁用 Aero,使用 ControlAero(true) 启用 Aero。 如果您使用的是 XP 或更早版本的 Windows 操作系统,此方法将返回 false,如果一切顺利且没有异常,则将返回 true。 您的应用程序关闭后,Aero 将自动启用。

历史

  • 2009 年 8 月 29 日:初始发布
© . All rights reserved.