DLL是用VC写的,里面函数原型是
DWORD _stdcall ReadPort(BYTE *PData,size_t iLen)给我的VB调用示例是
Declare Function ReadPort Lib“***.dll"(ByRef pData As Byte,ByVal iLen As Integer) As interger我用Delphi如下调用,却出错,请高手看看,是不是我调用的方式不对阿
function ReadPort( pData:array of byte;iLen:integer):integer;external'***.dll';使用的时候我是写  st:=ReadPort(ComBuf, 2);

解决方案 »

  1.   

    function ReadPort( pData:array of byte;iLen:integer):integer;stdcall;...
    implementation
    function ReadPort;external '***.dll' name 'ReadPort';
      

  2.   

    你是静态调用 还是动态的。。// 看起来是静态的。。function ReadPort( pData:array of byte;iLen:integer):integer;external'***.dll';
    + name '***' // 里面的函数名.你可能需要这么调用var
      comBuf: array of BYTE;SetLength(comBuf, 2);
    st := ReadPort(CombBuf, 2); 
      

  3.   


    function ReadPort( pData:pbyte;iLen:integer):integer;stdcall;external'***.dll';
      

  4.   

    关注,
    你的CombBuf在哪里分配空间,是主程序中还是dll中,如果你要针对CombBuf作一些类型转换的话,就要考虑在不同语言中数据类型是否一致。
      

  5.   

    function ReadPort( pData:array of byte;iLen:integer):integer;stdcall;external '***.dll';
      

  6.   

    function ReadPort( pData:PChar;iLen:integer):integer;external'***.dll';
      

  7.   

    function ReadPort( pData:PChar;iLen:integer):integer;external'***.dll';
    FillChar(ComBuf,sizeof(ComBuf),#0);
    ...
    st:=ReadPort(ComBuf, 2);
      

  8.   

    我用cdecl
    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