delphi下调用c写的dll老是出错,我想问一些delphi下怎么和c函数兼容,主要是指他的参数,象这样的函数:
int method(const int nReply, const int nLevel,
const char *sID, 
char *sID, int *nErrorCode,
const char cType,cPTotal=0,char cNumber=0);
这个函数是c的,delphi里怎么调用的时候怎么掉啊,参数应该怎么对应啊

解决方案 »

  1.   

    C里面DLL定义函数时使用stdcall关键字,而调用函数声明的时候也要用stdcall。请在本论坛里面搜索,这样的帖子像山一样多。
      

  2.   

    stdcall,cdecl,fastcall在运行时,都会出错,而且是调用一段时间后,个别的会抛read address...
    的错误,我想是参数传递引起的,不知道怎么解决
      

  3.   

    dll可不是我能控制的,dll应该没问题,不知道问题出在哪儿,查了很多关于Access violation at address  in module  Read of address 这样的解释都没找到原因,最要命的是偶尔会出错,如果全错了,都好办
      

  4.   

    int method(const int nReply, const int nLevel,
    const char *sID, 
    char *sID, int *nErrorCode,
    const char cType,cPTotal=0,char cNumber=0);
    因该这样申明吧!?
    function(nReply:integer;nLevel:integer;sID:pChar;var nErrorCode:integer;cType:Char;cPTotal:Char=0;cNumber:Char=0):integer;
    Char不行的话,可以用Byte替换。
      

  5.   

    function(nReply:integer;nLevel:integer;sID:pChar;var nErrorCode:integer;cType:Char;cPTotal:Char=0;cNumber:Char=0):integer;StdCall;external 'xxx.dll';