69,372
社区成员
发帖
与我相关
我的任务
分享
#include "windows.h"
#include "edr.h"
int WINAPI DllMain(HINSTANCE hInstance, DWORD fdwReason,PVOID pvReserved)
{
return TRUE;
}
//callback 为windows程序所要求u
//extern "C" __declspec(dllexport) 为动态链接库所要求 // 已经在头文件中定义
//若没有声明 则不能再dll外部调用
// 如果在C++中调用C语言写的dll 则dll要写上extern "C"
EXPORT BOOL CALLBACK EdrCenterTextA(HDC hdc,PRECT prc,PCSTR pString) // 多字节字符串
{
int iLength;
SIZE size;
iLength = lstrlenA(pString);
GetTextExtentPoint32A(hdc,pString,iLength,&size);
return TextOutA(hdc,(prc->right - prc->left -size.cx)/2,
(prc->bottom - prc->top -size.cy)/2,pString,iLength);
}
EXPORT BOOL CALLBACK EdrCenterTextW(HDC hdc, PRECT prc, PCWSTR pString)//宽字符字符串
{
int iLength;
SIZE size;
iLength = lstrlenW(pString);
GetTextExtentPoint32W(hdc,pString,iLength,&size);
return TextOutW(hdc,(prc->right - prc->left -size.cx)/2,
(prc->bottom - prc->top -size.cy)/2,pString,iLength);
}
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec(dllexport)
#endif
EXPORT BOOL CALLBACK EdrCenterTextA(HDC hdc,PRECT prc,PCSTR pString); // 多字节字符串
EXPORT BOOL CALLBACK EdrCenterTextW(HDC hdc, PRECT prc, PCWSTR pString);//宽字符字符串
#ifdef UNICODE // 根据属性设置中的unicode 判断
#define EdrCenterText EdrCenterTextW
#else
#define EdrCenterText EdrCenterTextA
#endif