专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > PB

急请诸位大侠帮忙看看PB声明外部函数?

发布时间:2011-06-29 17:49:44 文章来源:www.iduyao.cn 采编人员:星星草
急!!!请各位大侠帮忙看看PB声明外部函数???
Delphi 语法:
function BatchReadRecord(hPort: THandle; var Records: array of TICRecord{; ArraySize: Integer}): Integer; stdcall; external ER_API
//参数说明:
// hPort        : 端口句柄, 需要联机
// Records      : 返回记录数组, 最少需要16个单元
// ArraySize    : Delphi不需要,如果是VB或是C++需要传数组大小参数
//返回值:
// -1           : 错误
// 0            : 记录已经读完
// 1-16         : 正确读取的记录条数

//批读记录结构
type
  PICRecord=^TICRecord;
  TICRecord=packed record
    Card: array[0..19] of char; // 卡号字符串
    timeString: array[0..19] of char; // 14位刷卡时间字符串, 格式为yyyymmddhhnnss
    EmpId: array[0..9] of char;
    mark: Integer; // 读卡机标识字符
    flag: Integer; // 存储卡的结果
    cardTimes: Integer; // 发卡次数, 0-15
    consume  : Integer;    // 消费额
    balance  : Integer;    // 消费后余额
    pos_sequ: Integer; //消费流水号
    order_id: Integer;//卡重复使用序号
    OrderMonth   : Integer;  //订餐月
    OrderDay     : Integer;  //订餐日
    Dins1 : Integer;   //订餐1
    Dins2 : Integer;   //订餐2
    Month1 : Integer;   //月份1
    Month2 : Integer;  //月份2 
    reserved1: DWORD;             // 983返回的是状态
    reserved2: DWORD;             // 860返回的是班次
    reserved3: array[0..19] of Char; // 保留
    reserved4: array[0..100] of Char; // 机上原始数据
  end;

我的PB写法:
Declare Global external Functions 
function ulong BatchReadRecord(ulong hPort,ref TICRecord records,uint arraysize) Library "ER.DLL"

建立全局结构:
structure TICRecord 
  string     card[20] 
  string     timestring[20] 
  string     empid[10] 
  long   mark 
  long   flag 
  long   cardtimes 
  decimal{2}   consume 
  decimal{2}   balance 
  long   pos_sequ
  long   order_id
  long   OrderMonth
  long   OrderDay
  long   Dins1
  long   Dins2
  long   Month1
  long   Month2
  ulong   reserved1
  ulong   reserved2
  string   reserved3[20]
  string   reserved4[101]

代码:
ulong hPort,lui_ret
uint arraysize=20
TICRecord Records
lui_ret = BatchReadRecord(hPort,Records,arraysize)

为什么总报以下错误???
Error C0174:type of actual parameter cannot be ancester of formal reference parameter type
------解决思路----------------------
你结构体里long型 都换成Integer
ulong 换成long 试一下
------解决思路----------------------
ulong换成LongLong
------解决思路----------------------
PB中调用API函数如何处理DWORD类型
------解决思路----------------------


--我PB版本 9.0.3 8836
global type ticrecord from structure
string card[20]
string timestring[20]
string empid[10]
integer mark
integer flag
decimal{2} cardtimes
decimal{2} consume
integer balance
integer pos_sequ
integer order_id
integer ordermonth
integer orderday
integer dins1
integer dins2
integer month1
integer month2
longlong reserved1
longlong reserved2
string reserved3[20]
string reserved4[101]
end type

function long BatchReadRecord(ulong hPort,ref TICRecord records,integer arraysize) Library "eastriver.dll"

ulong hPort
long lui_ret
integer arraysize
arraysize=20
TICRecord Records

lui_ret = BatchReadRecord(hPort,Records,arraysize)

messagebox("",string(lui_ret))

如果还有错误,你和供应商要一下最新的开发包试一下,这个DLL是我在网上自己下的

友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: