我在vc中创建的一个传字符串参数的函数如下:
extern "C" _declspec(dllexport) bool test(char * name1, char *name2, char *name3);生成dll之后,delphi如何调用呢?

解决方案 »

  1.   

    在delphi钟声明:function ReadCardReq_Register(name1,name2,name3: pChar):Boolean; cdecl;
    external xxx.DLL';
      

  2.   

    晕 函数名写错了..
    function test(name1,name2,name3: pChar):Boolean; cdecl;
    external xxx.DLL';
      

  3.   

    是这样吗?
    function test( c:pchar; d:pchar ): boolean; cdecl;external 'Diff.DLL' name 'test';试了一下,的确可以。function test( c:pchar; d:pchar ): boolean; stdcall;external 'Diff.DLL' name 'test';为什么不行呢?能否讲讲stdcall cdecl的区别,如果要用stdcall,vc中应该怎么定义呢?谢谢!
      

  4.   

    extern "C" double __stdcall MyFunc(int a, double b); 
    extern "C" int  CdeclFunc(int a);   //By default this is a __cdecl convetionstdcall,cdecl区别是一个是从右边开始出栈,一个是从左边开始
      

  5.   

    Keyword       Stack cleanup      Parameter passing 
    __cdecl       Caller             Pushes parameters on the stack, in reverse order (right to left) __stdcall     Callee             Pushes parameters on the stack, in reverse order (right to left) __fastcall    Callee             Stored in registers, then pushed on stack thiscall (not a keyword) Callee  Pushed on stack; this pointer stored in ECX 注意有几点不同:
    1. 参数入栈方式
    2. 堆栈的清理方<有调用方/被调用方> 
    这些是很重要的 必须一致 否则调用错误。