Delphi 打开/关闭/判断Aero效果

来源:互联网 发布:成都市场不需要php了么 编辑:程序博客网 时间:2024/06/05 17:35
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;


                                             
0 0