繁体   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