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);
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);
implementation
function ReadPort;external '***.dll' name 'ReadPort';
+ name '***' // 里面的函数名.你可能需要这么调用var
comBuf: array of BYTE;SetLength(comBuf, 2);
st := ReadPort(CombBuf, 2);
function ReadPort( pData:pbyte;iLen:integer):integer;stdcall;external'***.dll';
你的CombBuf在哪里分配空间,是主程序中还是dll中,如果你要针对CombBuf作一些类型转换的话,就要考虑在不同语言中数据类型是否一致。
FillChar(ComBuf,sizeof(ComBuf),#0);
...
st:=ReadPort(ComBuf, 2);
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