Wednesday, February 23, 2011

Disabling Aero From Within a .NET Application Using DwmEnableComposition

First off, why would you want to disable the Aero theme? Well, it turns out that it messes with vsync and can screw up the framerate of some applications. DirectX apps seem to be ok, but, in my experience at least, it really messes with OpenGL.

To disable it from within a .NET application you need to DllImport dwmapi.dll. To do this you need to reference System.Runtime.InteropServices:

using System.Runtime.InteropServices;

Within one of your classes - usually where you have the application entry point - you need the following:

[DllImport("dwmapi.dll", PreserveSig = true)]
public static extern int DwmEnableComposition(bool enable);

To invoke the method, simply do this:



  1. Great, it works for me. I'm back at 60 fps in windowed mode, whereas with Aero it was 55 fps.


  2. Glad to hear it worked for someone else as well!