如何在VC调用dll中的有参数有返回值的函数
我的dll是这样定义的.extern "C" _declspec(dllexport) void go()
{
}
extern "C" _declspec(dllexport) int went(CString str)
{
return str.GetLength();
}
在MFC中调用如下:
typedef int (FAR _cdecl *MYWENT)(CString);
void CUsedllDlg::OnOK()
{
// TODO: Add extra validation here
HINSTANCE dllinstance;
dllinstance = ::LoadLibrary("E:\\Development\\C++\\mydll\\Debug\\mydll.dll");
if(dllinstance == NULL)
{
::AfxMessageBox("None",0,0);
}
FARPROC proc;
proc = ::GetProcAddress(dllinstance,"go");
if(proc == NULL)
{
::AfxMessageBox("None",0,0);
}
else
{
proc();
::AfxMessageBox("OK",0,0);
}
MYWENT went;
went = (MYWENT)::GetProcAddress(dllinstance,"went");
if(went == NULL)
{
::AfxMessageBox("NONE",0,0);
}
else
{
****** int i = went("wo");
::AfxMessageBox((CString)i,0,0);
}
::FreeLibrary(dllinstance);
//CDialog::OnOK();
}
*号指示的语句运行后出现Debug Assertion Failed!错误,并要求终止、重试、或取消
哪位知道出什么问题了?先行谢过。