【问题标题】:Function proto types / declarations for UxTheme.dll -dynamic- loadingUxTheme.dll -dynamic- loading 的函数原型类型/声明
【发布时间】:2016-05-23 01:43:13
【问题描述】:

使用 c++ Builder 2009,我正在尝试使用代码修复 Pre-Theme OS 问题,即在 Windows 2000 上程序启动期间未找到“UxTheme.dll”。

这是因为使用了许多功能:

OpenThemeData
DrawThemeBackground
DrawThemeEdge
CloseThemeData
GetThemePartSize

因为代码包含#include <UxTheme.hpp>(又包含:#include "uxtheme.h")并且项目链接UxTheme.lib静态加载dll。

我的(初始)目标是在没有此 dll 的操作系统上禁用需要这些功能的功能,但为此我需要动态加载 UxTheme.dll (LoadLibrary()) 并获取所需功能的地址 ( GetProcAddress())。 如果无法加载 dll 或函数,我可以禁用该功能或​​分配我自己的虚拟函数,讨厌的启动错误就会消失。

我无法理解函数原型所需的确切语法才能使用GetProcAddress() 等。所以我的第一个问题是,是否有人知道已经包含所有这些信息的头文件,和/或在公共域中执行函数指针分配的 ac(pp) 文件。或者,有人可以给我其中一个函数的标题和 cpp 语法示例(例如DrawThemeBackground),我应该能够弄清楚其余的!那么我还包括<UxTheme.hpp> 吗?

【问题讨论】:

    标签: c++ c dll c++builder


    【解决方案1】:

    我需要尝试一些错误,但__stdcall 是我需要的调用约定。我之前尝试过__cdecl,但这(显然)没有用。

    .h

    HTHEME (__stdcall *OpenThemeData)(
        HWND hwnd,
        LPCWSTR pszClassList
        );
    
    HRESULT (__stdcall *GetThemePartSize)(
        HTHEME hTheme,
        __in_opt HDC hdc,
        int iPartId,
        int iStateId,
        __in_opt LPCRECT prc,
        enum THEMESIZE eSize,
        __out SIZE *psz
        );
    
    HRESULT (__stdcall *DrawThemeBackground)(
        HTHEME hTheme,
        HDC hdc,
        int iPartId,
        int iStateId,
        LPCRECT pRect,
        __in_opt LPCRECT pClipRect
        );
    
    HRESULT (__stdcall *DrawThemeEdge)(
        HTHEME hTheme,
        HDC hdc,
        int iPartId,
        int iStateId,
        LPCRECT pDestRect,
        UINT uEdge,
        UINT uFlags,
        __out_opt LPRECT pContentRect
        );
    
    HRESULT (__stdcall * CloseThemeData)(
        HTHEME hTheme
        );
    

    .cpp

    OpenThemeData = (HTHEME (__stdcall *)(
            HWND hwnd,
            LPCWSTR pszClassList
            )) GetProcAddress (DllHandle, "OpenThemeData") ;
    
    GetThemePartSize = (HRESULT (__stdcall *)(
            HTHEME hTheme,
            __in_opt HDC hdc,
            int iPartId,
            int iStateId,
            __in_opt LPCRECT prc,
            enum THEMESIZE eSize,
            __out SIZE *psz
            )) GetProcAddress (DllHandle, "GetThemePartSize") ;
    
    DrawThemeBackground = (HRESULT (__stdcall *)(
            HTHEME hTheme,
            HDC hdc,
            int iPartId,
            int iStateId,
            LPCRECT pRect,
            __in_opt LPCRECT pClipRect
            )) GetProcAddress (DllHandle, "DrawThemeBackground") ;
    
    DrawThemeEdge = (HRESULT (__stdcall *)(
            HTHEME hTheme,
            HDC hdc,
            int iPartId,
            int iStateId,
            LPCRECT pDestRect,
            UINT uEdge,
            UINT uFlags,
            __out_opt LPRECT pContentRect
            )) GetProcAddress (DllHandle, "DrawThemeEdge") ;
    
    CloseThemeData = (HRESULT (__stdcall * )(
            HTHEME hTheme
            )) GetProcAddress (DllHandle, "CloseThemeData") ;
    

    现在一切正常,在 Win2K 上也是如此

    【讨论】:

      猜你喜欢
      • 2011-08-07
      • 2012-07-15
      • 2021-03-17
      • 1970-01-01
      • 1970-01-01
      • 2011-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多