我自己写了一个dll,其中有一个导出函数:
extern "C" void PASCAL EXPORT Test(CString str1,CString str2,......)我在vc里调用的时候这样的: HINSTANCE handlerDll=NULL;

typedef void (*Test)(CString,CString,.....);
Test  test; if(handlerDll==NULL)  
{
handlerDll=LoadLibrary("GZHBDll.dll");
}
test=(Test)GetProcAddress(handlerDll,"Test");

CTryApp* pApp=(CTryApp*)AfxGetApp();

CTestDllDlg testDllDlg;
if(testDllDlg.DoModal()==IDOK)
{
if(handlerDll==NULL)
{
AfxMessageBox("加载动态链接库失败!");
return;
}
test(str1,str2,......);
}
handlerDll=NULL;请各位大哥看看,这里错在哪里,为什么test函数可以执行,但是无论在哪里test返回总是有assert错误(test可以执行到底,但是一旦返回就错了)

解决方案 »

  1.   

    时不是这里?
    typedef void (*Test)(CString,CString,.....);
                  ^
    typedef void (PASCAL *Test)(CString,CSring,......);
      

  2.   

    不要在EXE和DLL间传递CString.它有很大的问题.
      

  3.   

    LINK : warning LNK4089: all references to "OLEAUT32.dll" discarded by /OPT:REF
    LINK : warning LNK4089: all references to "OLEPRO32.DLL" discarded by /OPT:REF
    LINK : warning LNK4089: all references to "RPCRT4.dll" discarded by /OPT:REF
    LINK : warning LNK4089: all references to "ole32.dll" discarded by /OPT:REF这样的警告怎么解决,是什么样的错误,好像就是在调用了我的dll后才出现的警告
      

  4.   

    not use CString in dll expert function,suggest you use LPCTSTR.
    the warning you can ignore it.
      

  5.   

    typedef void (PASCAL *Test)(CString,CSring,......);不要使用CString,尤其不要传CString值!
    建议使用LPCSTR 或LPSTR
      

  6.   

    我也遇到了同样的问题,我讲参数类型由CString改为了char*就OK了!!!
      

  7.   

    对阿!
    最好是传递地址!如char *