如何修复 UxTheme 中的延迟声明

发布于 2024-11-30 17:32:52 字数 1008 浏览 1 评论 0原文

在 Delphi XE UxTheme 单元中,有以下声明

function DrawThemeTextEx(hTheme: HTHEME; hdc: HDC; iPartId: Integer;  iStateId: Integer;
  pszText: LPCWSTR; cchText: Integer; dwTextFlags: DWORD; pRect: PRect;
  var pOptions: TDTTOpts): HResult; stdcall; 
  external themelib name 'DrawThemeTextEx' delayed;

我的 Windows XP Professional SP3 在 uxtheme.dll 中没有此类功能(使用来自 http://www.nirsoft.net/utils/dll_export_viewer.html)

看来我的应用程序延迟了程序的加载运行时失败并出现以下错误:

Project mtgstudio.exe raised exception class EExternalException 
with message 'External exception C0FB007F'.

JVCL 中也遇到了该问题,但按照 http://andy.jgknet.de/blog/2009/09/once-upon-a-delayed-jvcl-time/

我需要修复 UxTheme,因为它们由 DevExpress 组件使用以及。

有没有办法将 UxTheme.pas DrawThemeTextEx 声明修补/修复为非延迟?

In Delphi XE UxTheme unit there is the following declaration

function DrawThemeTextEx(hTheme: HTHEME; hdc: HDC; iPartId: Integer;  iStateId: Integer;
  pszText: LPCWSTR; cchText: Integer; dwTextFlags: DWORD; pRect: PRect;
  var pOptions: TDTTOpts): HResult; stdcall; 
  external themelib name 'DrawThemeTextEx' delayed;

My Windows XP Professional with SP3 does not have such function in the uxtheme.dll (checked with dllexp.exe from http://www.nirsoft.net/utils/dll_export_viewer.html)

It seems like my application does delayed loading of the procedure and fails runtime with the following error:

Project mtgstudio.exe raised exception class EExternalException 
with message 'External exception C0FB007F'.

The issue was encountered in JVCL as well but resolved there as per http://andy.jgknet.de/blog/2009/09/once-upon-a-delayed-jvcl-time/

I need UxTheme fixed because they are used by the DevExpress components as well.

Is there a way to patch/fix the UxTheme.pas DrawThemeTextEx declaration to be non-delayed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

安静被遗忘 2024-12-07 17:32:52

根本问题是这个API是在Vista中引入的,在XP中不可用。

Delayed 关键字的全部目的是让想要利用更新的 API 函数的开发人员可以轻松地使用此类函数。但要做到这一点,开发人员通常还必须为旧操作系统版本提供后备实现,而 DevExpress 似乎未能做到这一点。

因此,该错误不在 UxTheme.pas 中,而是在调用未在平台上实现的 API 的 DevExpress 组件中。修复方法是重新编写 DevExpress 代码以避免在 XP 上调用此 API。

我建议您联系 DevExpress,他们很可能已经在最新版本中修复了这个问题。

The fundamental problem is that this API was introduced in Vista and is not available in XP.

The whole point of the delayed keyword is to allow functions like this to be made available easily to developers who want to take advantage of newer API functions. But to do so the developer typically must also provide fallback implementations for older OS versions, which DevExpress appear to have failed to do.

The bug is therefore not in UxTheme.pas, but in the DevExpress component that calls an API that is not implemented on the platform. The fix is to re-work the DevExpress code to avoid calling this API on XP.

I suggest you contact DevExpress who quite probably already have a fix in their latest versions.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文