extern "C" __declspec(dllexport) int __stdcall  DataIE
(CWnd* pWnd 
    , _ConnectionPtr pConn 
    , int iStyle //类型:1导入 0导出
             , .........
    )
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
//CDataIEDlg dlg(pWnd);
CDataIEDlg dlg;
dlg.pConn = pConn;
dlg.iStyle = iStyle;
............
dlg.DoModal();
         return 1;
}
调用正常,就是DELPHI主程序退出时异常!什么原因?

解决方案 »

  1.   

    我dialog退出时就是调用OnOK(),退出,dialog也没有用到什么指针之类的,用了一个_ConnectionPtr pConn ,退出的时候也给了NULL,
    退出时第一个错误对话框
    "0x00000000"指令引用的"0x00000000"内存.该内存不能为"read"
    2:
    Exception EAccessViolation in module a.exe at 00000000.
    Access violation at address 0000000.read of address 00000000.
      

  2.   

    如果把__stdcall  改成 __cdecl则退出我的窗口的时候同时关掉Delphi主程序摸了半天了都没摸出来,能想到的都试过了改delphi程序也试了,各种组合基本上都试过了,不是这问题就是那问题
    高人指点点指吧
      

  3.   

    这次调试DLL,结束程序后进程老不结束,强行终止进程,VC"Debug"信息:
    First-chance exception in GasJar.exe: 0xC0000005: Access Violation.
    //上面这行一共有8000多行!!!
    The thread 0x9FC has exited with code 1 (0x1).
    The thread 0x87C has exited with code 1 (0x1).
    The thread 0x904 has exited with code 1 (0x1).
    The thread 0x994 has exited with code 1 (0x1).
    The program 'F:\Silly\Debug\GasJar.exe' has exited with code 1 (0x1).
    这是什么回事?
      

  4.   

    应该用_stdcall的方式调用函数。
      

  5.   

    有参数的用 cdecl 试试如: 
    p: Function (Key1_Mouse2:integer ):boolean;cdecl;// stdcall;   
      

  6.   

    我重新在DELPHI
    版开了一个帖http://community.csdn.net/Expert/topic/3086/3086312.xml?temp=.409878
    解决了一并给分,并且可以再开贴给分!!!!TO  hhhaaa(hhhaaa)
    这样的话参数传递失败!!!