Been trying to use the following code in order to check if Windows Aero is enabled:
function AeroEnabled: boolean;
var
enabled: bool;
begin
// Function from the JwaDwmapi unit (JEDI Windows Api Library)
DwmIsCompositionEnabled(enabled);
Result := enabled;
end;
...
if (CheckWin32Version(5,4)) and (AeroEnabled) then
CampaignTabs.ColorBackground := clBlack
else begin
GlassFrame.Enabled := False;
CampaignTabs.ColorBackground := clWhite;
end;
However, doing so on a pre-vista machine causes the app to crash because the DWMApi.dll is missing. I’ve also tried this code however it produces 2 AV’s in a row. How can I do this ? I am using Delphi 2010. 🙂
You’ve got your versions wrong. Vista/2008 server are version 6.0. Your test should be:
I believe that you are using Delphi 2010 or later in which case you should simply call the
DwmCompositionEnabledfunction from the built-inDwmapiunit. This organises the version check and the delayed binding for you. No need for JEDI.Edit: Text below was written before the question was edited.
Probably the easiest approach is to check the Windows version. You need
Win32MajorVersion>=6(i.e. Vista or 2008 server) in order to callDwmIsCompositionEnabled.If you were binding yourself then you would call
LoadLibrarywithDWMApi.dlland if that succeeded you would then callGetProcAddressto bind. If that succeeded you are good. But, as I said, since you aren’t handling the binding yourself then a version check is probably the simplest.So the function would be:
Note, I’m assuming that your library is doing late binding, i.e. explicit linking. If not then you’ll need LoadLibrary/GetProcAddress, exactly as is done in @RRUZ’s code to which you link.