如何检测Delphi 7上的Windows Aero主题?

如何检测用户是通过Delphi 7上的代码在他的操作系统上运行Windows Aero主题?

我们需要使用的函数是Dwmapi.DwmIsCompositionEnabled ,但是这并不包含在Delphi 7附带的Windows头文件中,并且在Delphi 7中添加了,并且在Delphi 7中发布。它也在Windows XP上崩溃了,所以在之后调用它检查if Win32MajorVersion >= 6

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