简单的的很难吗?
1。
在VC,file.C 里面编译可以定义
PROC lpAdder = MessageBoxA;
在VC,file.CPP里面编译时却不可以定义????
PROC lpAdder = MessageBoxA;
int WINAPI MyMesageBoxA(
HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
)
{
return lpAdder(NULL,lpText,lpCaption,uType);//
}
难道C++里面不可以这样定义?
把MessageBox(HWND , LPCTSTR ,LPCTSTR ,UINT )转换成(CALLBACK *PROC)(),无参数型的?
谢谢!
[解决办法]
typedef int (WINAPI *PFNMESSAGEBOX)(HWND hWnd,LPCTSTR lpText,LPCTSTR lpCaption,UINT uType);
int WINAPI MyMesageBoxA(
HWND hWnd, // handle of owner window
LPCTSTR lpText, // address of text in message box
LPCTSTR lpCaption, // address of title of message box
UINT uType // style of message box
)
{
return ((PFNMESSAGEBOX)(lpAdder))(NULL,lpText,lpCaption,uType); //函数签名转换
}
[解决办法]