如何在Windows 8或更高版本中启用或禁用AERO Composition? [英] How enable or disable AERO Composition in Windows 8 or higher?
问题描述
我有一个更新的代码,可以很好地在Windows Vista和Windows 7中启用或禁用AERO Composition。但是,当在Windows 8系统中使用时,此相同的代码不起作用。我在其他网站中看到了Windows 8,不能以编程方式禁用AERO Composition。因此,想知道是否有偶然的机会,有人在Delphi中具有某些功能或过程可以在Windows 8或更高版本的系统中实现该目标?
欢迎提出任何建议。
这是我在Windows Vista和Windows 7中启用或禁用AERO Composition的代码:
函数ISAeroEnabled:布尔值;
类型
_DwmIsCompositionEnabledFunc = function(var IsEnabled:boolean)
:HRESULT; stdcall;
var
标志:布尔值;
DllHandle:多;
OsVersion:TOSVersionInfo;
DwmIsCompositionEnabledFunc:_DwmIsCompositionEnabledFunc;
开始
结果:= false;
ZeroMemory(@OsVersion,Sizeof(OsVersion));
OsVersion.dwOSVersionInfoSize:= Sizeof(TOSVersionInfo);
if(((GetVersionEx(OsVersion)))和
(OsVersion.dwPlatformId = VER_PLATFORM_WIN32_NT)和
(OsVersion.dwMajorVersion> = 6))然后
开始
DllHandle:= LoadLibrary('dwmapi.dll');
如果DllHandle<>尝试
0然后
开始
@DwmIsCompositionEnabledFunc:= GetProcAddress(DllHandle,
'DwmIsCompositionEnabled');
如果(@DwmIsCompositionEnabledFunc nil)则
开始
如果DwmIsCompositionEnabledFunc(Flag)= S_OK然后
结果:=标志;
结尾;
结尾;如果DllHandle<>最终
0然后
FreeLibrary(DllHandle);
结尾;
结尾;
结尾;
程序AeroSetEnable(enable:boolean);
const
DWM_EC_DISABLECOMPOSITION = 0;
DWM_EC_ENABLECOMPOSITION = 1;
var
DWMlibrary:THandle;
开始
DWMlibrary:= LoadLibrary(’DWMAPI.dll’);如果DWMlibrary<> ;,则
如果@DwmEnableComposition<> 0,则
从
开始。 nil,然后
如果没有启用,则开始
;如果不是ISAeroEnabled,则开始
;然后
开始
DwmEnableComposition(DWM_EC_ENABLECOMPOSITION)
结束;
结束
否则开始DwmEnableComposition(DWM_EC_DISABLECOMPOSITION);结束;
结尾;
结尾;
结尾;
从Windows 8起不推荐使用此功能。无法通过编程方式禁用DWM。
$ b从Windows 8开始,
$ b
和
用DWM_EC_DISABLECOMPOSITION调用此函数无效。但是,该函数仍将返回成功代码。
该文档明确指出,不能在Windows 8中禁用该组合。 / p>
I have a updated code that works fine for enable or disable AERO Composition in Windows Vista and Windows 7. But this same code don't works when is used in Windows 8 systems. I saw in other website that from of Windows 8, AERO Composition can no longer be programmatically disabled. So, want know if by chance, someone here have some function or procedure in Delphi that works for this goal in Windows 8 systems or higher?
Any suggestion are welcome.
Here is my code for enable or disable AERO Composition in Windows Vista and Windows 7:
function ISAeroEnabled: boolean;
type
_DwmIsCompositionEnabledFunc = function(var IsEnabled: boolean)
: HRESULT; stdcall;
var
Flag: boolean;
DllHandle: thandle;
OsVersion: TOSVersionInfo;
DwmIsCompositionEnabledFunc: _DwmIsCompositionEnabledFunc;
begin
Result := false;
ZeroMemory(@OsVersion, Sizeof(OsVersion));
OsVersion.dwOSVersionInfoSize := Sizeof(TOSVersionInfo);
if ((GetVersionEx(OsVersion)) and
(OsVersion.dwPlatformId = VER_PLATFORM_WIN32_NT) and
(OsVersion.dwMajorVersion >= 6)) then
begin
DllHandle := LoadLibrary('dwmapi.dll');
try
if DllHandle <> 0 then
begin
@DwmIsCompositionEnabledFunc := GetProcAddress(DllHandle,
'DwmIsCompositionEnabled');
if (@DwmIsCompositionEnabledFunc <> nil) then
begin
if DwmIsCompositionEnabledFunc(Flag) = S_OK then
Result := Flag;
end;
end;
finally
if DllHandle <> 0 then
FreeLibrary(DllHandle);
end;
end;
end;
procedure AeroSetEnable(enable: boolean);
const
DWM_EC_DISABLECOMPOSITION = 0;
DWM_EC_ENABLECOMPOSITION = 1;
var
DWMlibrary: THandle;
begin
DWMlibrary:= LoadLibrary('DWMAPI.dll');
if DWMlibrary <> 0 then
begin
if @DwmEnableComposition <> nil then
begin
if enable then begin
if not ISAeroEnabled then
begin
DwmEnableComposition(DWM_EC_ENABLECOMPOSITION)
end;
end
else begin DwmEnableComposition(DWM_EC_DISABLECOMPOSITION); end;
end;
end;
end;
The documentation for DwmEnableComposition
says:
This function is deprecated as of Windows 8. DWM can no longer be programmatically disabled.
and
As of Windows 8, calling this function with DWM_EC_DISABLECOMPOSITION has no effect. However, the function will still return a success code.
This documentation states, unequivocally, that composition cannot be disabled from Windows 8.
这篇关于如何在Windows 8或更高版本中启用或禁用AERO Composition?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!