Jef*_*eff 0 delphi aero dwm jedi-code-library
尝试使用以下代码来检查 Windows Aero 是否已启用:
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;
Run Code Online (Sandbox Code Playgroud)
但是,在 Vista 之前的计算机上执行此操作会导致应用程序崩溃,因为缺少 DWMApi.dll。我也尝试过这段代码,但是它连续生成 2 个 AV。我怎样才能做到这一点 ?我正在使用 Delphi 2010。:)
你的版本错了。Vista/2008 服务器版本为 6.0。你的测试应该是:
CheckWin32Version(6,0)
Run Code Online (Sandbox Code Playgroud)
我相信您使用的是 Delphi 2010 或更高版本,在这种情况下您应该简单地DwmCompositionEnabled从内置Dwmapi单元调用该函数。这会为您组织版本检查和延迟绑定。不需要绝地武士。
编辑:下面的文字是在编辑问题之前编写的。
最简单的方法可能是检查 Windows 版本。您需要Win32MajorVersion>=6(即 Vista 或 2008 服务器)才能调用DwmIsCompositionEnabled.
如果您正在绑定自己,那么您将调用LoadLibrarywith DWMApi.dll,如果成功,您将调用GetProcAddressbind 。如果成功了,那你就很好了。但是,正如我所说,由于您不自己处理绑定,因此版本检查可能是最简单的。
所以函数是:
function AeroEnabled: boolean;
var
enabled: bool;
begin
if Win32MajorVersion>=6 then begin
DwmIsCompositionEnabled(enabled);
Result := enabled;
end else begin
Result := False;
end;
end;
Run Code Online (Sandbox Code Playgroud)
请注意,我假设您的库正在执行后期绑定,即显式链接。如果没有,那么您将需要 LoadLibrary/GetProcAddress,正如您链接到的 @RRUZ 代码中所做的那样。
| 归档时间: |
|
| 查看次数: |
1524 次 |
| 最近记录: |