我有一个更新的代码,可以在Windows Vista和Windows 7中启用或禁用AERO合成。但在Windows 8系统中使用时,此相同的代码不起作用。我在other website中看到,从Windows 8开始,AERO Composition无法再以编程方式禁用。那么,想知道是否偶然,这里有人在Delphi中有一些功能或程序在Windows 8系统或更高版本中适用于这个目标?
欢迎任何建议。
这是我在Windows Vista和Windows 7中启用或禁用AERO合成的代码:
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;
DwmEnableComposition
的文档说:
从Windows 8开始,不推荐使用此功能。无法再以编程方式禁用DWM。
和
从Windows 8开始,使用DWM_EC_DISABLECOMPOSITION调用此函数无效。但是,该函数仍将返回成功代码。
该文档明确指出,无法从Windows 8禁用该组合。
解: