help!!!
我用stdcall可以执行回调函数,但showmessage('kkkkkk')之后,退出回调函数时出错(非法访问内存)。
此dll的其它函数(不须回调函数参数)用cdecl没问题,而用stdcall同样有非法访问内存错误。
这是为什么???

解决方案 »

  1.   


    he default register convention is the most efficient, since it usually avoids creation of a stack frame. (Access methods for published properties must use register.) The cdecl convention is useful when you call functions from DLLs written in C or C++, while stdcall and safecall are used for Windows API calls. The safecall convention must be used for declaring dual-interface methods. The pascal convention is maintained for backward compatibility. For more information on calling conventions, see 
      

  2.   

    cdecl和stdcall的区别是谁clean-up the parameters from the stack,caller or routine?
      And now,if I use the 'cdecl' then  the programme have no errors on clean-up but can't run the callback fun,if I use the 'stdcall' then it can run the callback fun but it will occur errors on clean-up parameters.
      why? What can I do for it? Thanks!
      

  3.   


      你的dll里的函数申明是也要是 cdecl,?
      

  4.   

    dll是别人写的,源码我没有,但我在
    typedef  void (*FT_PLUG_AND_PLAY_MONITOR) (IN FT_DEVICE_STATUS_PT);
    后加上cdecl也一样不执行回调函数。
    现在我怀疑是否是此dll没写好.回调函数的此声明,定义方法用于winapi的enumwindows和另一dll(moxa厂家提供)都没问题。
      另外释放参数出错,有什么方法可以解决呢?非常感谢airhorse的关注!
      

  5.   


    FT_DEVICE_STATUS_CODE :?
      

  6.   

    typedef enum
    {
    FT_DEVICE_PLUGGED,
    FT_DEVICE_UNPLUGGED,
    FT_UNKNOWN_ERROR,            /* error monitoring devices */
    FT_DEVICE_ERROR
    }
    FT_DEVICE_STATUS_CODE, *FT_DEVICE_STATUS_CODE_PT;
    typedef __int64 FT_DEVICE_ID;            /* device id */  
      

  7.   

    最好改成pascal调用。
    在delphi中把cdecl去掉,在C中加上pascal修饰符,也许能解决问题。
      

  8.   

    在c的头文件加pascal修饰符吗?where? Thanks!