簡體   English   中英

如何在Delphi 7上檢測Windows Aero主題?

[英]How to detect Windows Aero theme on Delphi 7?

您如何通過Delphi 7上的代碼檢測到用戶正在其操作系統上運行Windows Aero主題?

我們需要使用的功能是Dwmapi.DwmIsCompositionEnabled ,但該功能未包含在Delphi 7附帶的Windows標頭轉換中,該功能已在Delphi 7之后發布的Vista中添加。此外,它還會使Windows XP上的應用程序崩潰-請在之后調用它檢查if Win32MajorVersion >= 6

function IsAeroEnabled: Boolean;
type
  TDwmIsCompositionEnabledFunc = function(out pfEnabled: BOOL): HRESULT; stdcall;
var
  IsEnabled: BOOL;
  ModuleHandle: HMODULE;
  DwmIsCompositionEnabledFunc: TDwmIsCompositionEnabledFunc;
begin
  Result := False;
  if Win32MajorVersion >= 6 then // Vista or Windows 7+
  begin
    ModuleHandle := LoadLibrary('dwmapi.dll');
    if ModuleHandle <> 0 then
    try
      @DwmIsCompositionEnabledFunc := GetProcAddress(ModuleHandle, 'DwmIsCompositionEnabled');
      if Assigned(DwmIsCompositionEnabledFunc) then
        if DwmIsCompositionEnabledFunc(IsEnabled) = S_OK then
          Result := IsEnabled;
    finally
      FreeLibrary(ModuleHandle);
    end;
  end;
end;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM