function OpenAero():Boolean;
const
DWM_EC_ENABLECOMPOSITION = 1;
var
h:HWND;
DwmEnableComposition:function(uCompositionAction:Cardinal):THandle; stdcall;
begin
Result:=False;
h:=LoadLibrary('dwmapi.dll');
if h <> 0 then
begin
@DwmEnableComposition:=GetProcAddress(h,'DwmEnableComposition');
if @DwmEnableComposition <> nil then
begin
if DwmEnableComposition(DWM_EC_ENABLECOMPOSITION) = 0 then
begin
Result:=True;
end;
end;
end;
end;
function CloseAero():Boolean;
const
DWM_EC_DISABLECOMPOSITION = 0;
var
h:HWND;
DwmEnableComposition:function(uCompositionAction:Cardinal):THandle; stdcall;
begin
Result:=False;
h:=LoadLibrary('dwmapi.dll');
if h <> 0 then
begin
@DwmEnableComposition:=GetProcAddress(h,'DwmEnableComposition');
if @DwmEnableComposition <> nil then
begin
if DwmEnableComposition(DWM_EC_DISABLECOMPOSITION) = 0 then
begin
Result:=True;
end;
end;
end;
end;
function IsOpenAero():Boolean;
var
h:HWND;
b:Boolean;
DwmIsCompositionEnabled:function(var retbool:Boolean):THandle; stdcall;
begin
Result:=False;
h:=LoadLibrary('dwmapi.dll');
if h <> 0 then
begin
@DwmIsCompositionEnabled:=GetProcAddress(h,'DwmIsCompositionEnabled');
if @DwmIsCompositionEnabled <> nil then
begin
DwmIsCompositionEnabled(b);
if b then
begin
Result:=True;
end;
end;
end;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
if IsOpenAero() then
begin
ShowMessage('开启了Aero');
end else begin
ShowMessage('未开启Aero');
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
CloseAero();
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
OpenAero();
end;
Delphi 打开/关闭/判断Aero效果
最新推荐文章于 2024-09-10 09:56:01 发布