比如我们用的是 vs2008 然后创建一个mfc dll
默认他里面有一个class
我在这个class上面添加了方法,
#define DllExport __declspec(dllexport)
class CdllApp : public CWinApp
{
....
DllExport void test(CString string);//实现就是 MessageBox(NULL,string,0,0);
....
}当外面用loadlibrary的时候,使用这个方法,也能弹出messagebox对话框
但当那个实现改成 MessageBox(NULL,string,this->title,0);
这里 title是CdllApp的一个成员变量 
调用 就出错请各位好心人帮下忙

解决方案 »

  1.   

    解决了,居然还可以这样用....
    // CdllAppBEGIN_MESSAGE_MAP(CdllApp, CWinApp)
    END_MESSAGE_MAP()
    // CdllApp constructionCdllApp::CdllApp()
    : title(_T(""))
    {
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
    }
    // The one and only CdllApp objectCdllApp theApp;
    // CdllApp initializationBOOL CdllApp::InitInstance()
    {
    CWinApp::InitInstance();
    this->title.Format(_T("title"));
    return TRUE;
    }DllExport void CdllApp::test(CString string)
    {
    MessageBox(NULL,string,theApp.title,0);
    }