我们需要使用的功能是Dwmapi.DwmIsCompositionEnabled,但这不包含在随Delphi 7一起提供的Windows头文件中,并且在Vista中添加,在Delphi 7之后发布.它也会在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;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1734 次 |
| 最近记录: |