使用c ++ Builder 2009,我试图用代码解决Pre-Theme OS问题,即" UxTheme.dll"在Windows 2000上,在程序启动期间找不到。
这是因为使用了许多功能:
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>
吗?
答案 0 :(得分:0)
我需要一些试验错误,但__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上