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;
SOLUTION:
Enable
ShellExecute(0, nil, 'cmd.exe', '/C net start uxsms', nil, SW_HIDE);
Disable
ShellExecute(0, nil, 'cmd.exe', '/C net stop uxsms', nil, SW_HIDE);
The documentation for
DwmEnableComposition
says:and
This documentation states, unequivocally, that composition cannot be disabled from Windows 8.