1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| // Vérifie si l'OS est Windows Vista
function IsWindowsVista(): Boolean;
var
VerInfo: TOSVersioninfo;
begin
VerInfo.dwOSVersionInfoSize := SizeOf(TOSVersionInfo);
GetVersionEx(VerInfo);
Result := VerInfo.dwMajorVersion >= 6;
end;
// Vérifie si la composition du bureau est activée
function CompositingEnabled(): Boolean;
var
DLLHandle: THandle;
DwmIsCompositionEnabled: function(pfEnabled: PBoolean): HRESULT; stdcall;
Enabled: Boolean;
begin
Result := False;
if IsWindowsVista() then
begin
DLLHandle := LoadLibrary('dwmapi.dll');
if DLLHandle <> 0 then
begin
@DwmIsCompositionEnabled :=
GetProcAddress(DLLHandle, 'DwmIsCompositionEnabled');
if (@DwmIsCompositionEnabled <> Nil) then
begin
DwmIsCompositionEnabled(@Enabled);
Result := Enabled;
end;
FreeLibrary(DLLHandle);
end;
end;
end;
// Désactive la composition du bureau
function DisableComposing(Disable: Boolean = True): Boolean;
const
DWM_EC_DISABLECOMPOSITION = 0;
DWM_EC_ENABLECOMPOSITION = 1;
var
DLLHandle: THandle;
DwmEnableComposition: function(uCompositionAction: UINT): HRESULT; stdcall;
begin
Result := False;
if CompositingEnabled() then
begin
DLLHandle := LoadLibrary('dwmapi.dll');
if DLLHandle <> 0 then
begin
@DwmEnableComposition :=
GetProcAddress(DLLHandle, 'DwmEnableComposition');
if @DwmEnableComposition <> Nil then
if Disable then
Result := (DwmEnableComposition(DWM_EC_DISABLECOMPOSITION) = S_OK)
else
Result := (DwmEnableComposition(DWM_EC_ENABLECOMPOSITION) = S_OK);
end;
end;
end; |
Partager