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 application is running

#include <dwmapi.h>

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

thank

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%
+3
source share
1 answer

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.
}
+4
source

Source: https://habr.com/ru/post/1770168/


All Articles