来自《windows程序设计》:请理解每一句的意思
#ifdef _cplusplus
#define EXPORT extern "C" _declspec(dllexport)
#else
#define EXPORT _declspec(dllexport)
#endif
EXPORT BOOL CALLBACK CenterText(HDC, PRECT, PCSTR);
|
OK,我们可以写实现文件了:
#include <windows.h>
#include "dll.h"
int WINAPI DllMain(HINSTANCE hInstance,
DWORD fdwReason,
PVOID pvReserved) {
return TRUE;
}
EXPORT BOOL CALLBACK CenterText(HDC hdc,
PRECT pRect,
PCSTR cStr) {
int iLength;
SIZE size;
iLength = strlen(cStr);
GetTextExtentPoint32(hdc, cStr, iLength, &size);
TextOut(hdc, (pRect->right - pRect->left - size.cx) / 2,
(pRect->bottom - pRect->top - size.cy) / 2,
cStr, iLength);
}
|
阅读(2490) | 评论(0) | 转发(0) |