2010-10-18 127 views
3

如何在C#.NET或C++ Win32中禁用Aero效果?在C#/ VB.NET或C++中启用/禁用Aero Win32

这是C/C++我的测试代码,但只工作,如果我的应用程序运行过程中出现

#include <dwmapi.h> 

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

感谢

编辑:我想通了

#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% 
+0

你想永久tly禁用它们为用户? – 2010-10-18 18:23:46

+0

你想做什么? – SLaks 2010-10-18 18:25:08

回答

4

这应该工作:

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

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

    // Your application here. 
}