2010-10-18 63 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. 
}