//MyRegularDll.hclass CMyRegularDllApp : public CWinApp
{
public:
CMyRegularDllApp(); int ok;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CMyRegularDllApp)
//}}AFX_VIRTUAL //{{AFX_MSG(CMyRegularDllApp)
// NOTE - the ClassWizard will add and remove member functions here.
//    DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};------------------
//MyRegularDll.cppextern "C" BOOL PASCAL EXPORT ExportedFunction(int a)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
// normal function body here
ok=a;
return true;
}比如我想在以上函数中调用CMyRegularDllApp::ok成员函数;
但是,我这样写,不成功,说"error C2065: 'ok' : undeclared identifier"

解决方案 »

  1.   

    extern CMyRegularDllApp theApp;extern "C" BOOL PASCAL EXPORT ExportedFunction(int a)
    {
        AFX_MANAGE_STATE(AfxGetStaticModuleState());    // normal function body here
        theApp.ok();    return TRUE;
    }
      

  2.   

    如 In355Hz(好象一条狗) 说:extern CMyRegularDllApp theApp;extern "C" BOOL PASCAL EXPORT ExportedFunction(int a)
    {
        AFX_MANAGE_STATE(AfxGetStaticModuleState());    // normal function body here
        theApp.ok();    return TRUE;
    }