65.9K
CodeProject is changing. Read more.
Home

Enabling and Disabling Aero interface on Windows Vista and 7

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.14/5 (11 votes)

Aug 29, 2009

CPOL
viewsIcon

39420

downloadIcon

480

Is Aero causing your application to become unstable? Jump in...

Introduction 

Is your application incompatible with Aero interface? Do you want to disable Aero from your application? You are in the right place.

Using the Code

Using this code is really simple, almost anyone can use it easily.

Just add System.Runtime.InteropServices to your usings and paste this code into the application.

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; }
}

You can disable Aero with ControlAero(false), and enable Aero with ControlAero(true). If you are on an XP or prior Windows operating system, this method will return false, if everything is done without an exception, it will return true. After your application is closed, Aero will get enabled automatically.

History

  • 29th August, 2009: Initial post