ale
ale

Reputation: 33

Enable / Disable Aero in C#/VB.NET or C++ Win32

How to disable aero effects in C# .NET or C++ Win32 ???

This is my test code in C/C++, but only works if my app is runnig

#include <dwmapi.h>

int main()
{ 
    DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);
    while(true); 
     //...
    return 0;
}
//LINK dwmapi.lib

Thanks

Edit: i figured it out

#include <Windows.h>
#include <dwmapi.h>

int WINAPI WinMain(HINSTANCE hI, HINSTANCE hP, PSTR str, int c)
{ 
    DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);
    MSG msg;
    ZeroMemory(&msg, sizeof(MSG));
    while(GetMessage(&msg, 0, 0, 0))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }
    return 0;
}
//Memory: 314KB
//CPU: 0%

Upvotes: 3

Views: 3460

Answers (2)

Declare Sub DwmEnableComposition Lib "dwmapi.dll" Alies "DwmEnableComposition (uComposition As Action UInt32)

Designer Form.vb

Public Class DesignerForm
   Private Sub DesignerForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
       DwmEnableComposition(Convert.ToInt32(0)
   End Sub
End Class

Upvotes: -2

Pieter van Ginkel
Pieter van Ginkel

Reputation: 29632

This should work:

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

static void Main(string[] args)
{
    DwmEnableComposition(false);

    // Your application here.
}

Upvotes: 4

Related Questions