Detect Aero Glass using Delphi

Submitted by:Pitter Alderson

Date added:25 January, 2014

Category:Delphi

To detect if Aero Glass is enabled we must use the DwmIsCompositionEnabled function.

Tags: delphi function , aero glass

Code Snippet:

program DetectAeroDelphi;
{$APPTYPE CONSOLE}
//Author Rodrigo Ruz 2009-10-26
uses
Windows,
SysUtils;

function ISAeroEnabled: Boolean;
type
_DwmIsCompositionEnabledFunc = function(IsEnabled: PBoolean): HRESULT; stdcall;
var
Flag : Boolean;
DllHandle : THandle;
OsVersion : TOSVersionInfo;
DwmIsCompositionEnabledFunc: _DwmIsCompositionEnabledFunc;
begin
Result:=False;
ZeroMemory(@OsVersion, SizeOf(OsVersion));
OsVersion.dwOSVersionInfoSize := SizeOf(TOSVERSIONINFO);

if ((GetVersionEx(OsVersion)) and (OsVersion.dwPlatformId = VER_PLATFORM_WIN32_NT) and (OsVersion.dwMajorVersion >= 6)) then //is Vista or Win7?
begin
DllHandle := LoadLibrary('dwmapi.dll');
if DllHandle <> 0 then
begin
@DwmIsCompositionEnabledFunc := GetProcAddress(DllHandle, 'DwmIsCompositionEnabled');
if (@DwmIsCompositionEnabledFunc <> nil) then
begin
DwmIsCompositionEnabledFunc(@Flag);
Result:=Flag;
end;
end;
FreeLibrary(DllHandle);
end;
end;

begin
try
if ISAeroEnabled then
Writeln('Aero Glass enabled')
else
Writeln('Aero Glass disabled');
Readln;
except
on E:Exception do
Writeln(E.Classname, ': ', E.Message);
end;
end.
 
 

Comments