DLL头文件FileTransferSvr.h源码:
#include <windows.h>
#include <afxwin.h>extern "C" __declspec(dllexport) int MsgBox(CString msg);CPP文件FileTransferSvr.cpp源码:
#include <afxwin.h>
#include "FileTransferSvr.h"int MsgBox(CString msg)
{
return MessageBox(NULL,msg,"一个简单的例子",MB_OK);
}生成了FileTransferSvr.Dll后,在一个对话框程序里调用,调用的代码段如下:
void CTestDEComRecDlg::OnOK() 
{
typedef int (CALLBACK* DLLFUNC)(CString a);
CString msg = "测试DLL成功!";
HINSTANCE hDLL;
DLLFUNC msgbox;
hDLL = LoadLibrary("FileTransferSvr");
if(hDLL!=NULL)
{
msgbox = (DLLFUNC)::GetProcAddress(hDLL,"MsgBox");
msgbox(msg);
::FreeLibrary(hDLL);
}
else
{
AfxMessageBox("Load dll failed!");
}
}点击了对话框的“OK”按钮后,如我所愿,确实弹出了“测试DLL成功!”
的提示框,但当我点击MessageBox上的“确定”按钮后,却引发了如下异常:Debug error!
Program:...Visual studio\MyProjects\...\Debug\TestDEComRec.exe
Module:
File:i386\chkesp.c
line:42The value of ESP was not property saved across a function call.this is
usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling 
convention.我的代码哪里有问题啊?!盼高手指点迷津!!!!另:我的操作系统是windows2000,开发环境是VC6.0