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

小月云 2012-10-13 11:03:17
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
...全文
792 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
WorldMobile 2012-10-14
  • 打赏
  • 举报
回复
array[0..100] of Char 应该相当于pb的String

或者用 char aa[100]试试
a954105626 2012-10-13
  • 打赏
  • 举报
回复
我刚打开电脑我试一下
小月云 2012-10-13
  • 打赏
  • 举报
回复
[Quote=引用 8 楼 的回复:]
PB中调用API函数如何处理DWORD类型
[/Quote]

请问我的外部函数声明有没有问题?
小月云 2012-10-13
  • 打赏
  • 举报
回复
[Quote=引用 6 楼 的回复:]
ulong换成LongLong
[/Quote]
也一样!
小月云 2012-10-13
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 的回复:]
你结构体里long型 都换成Integer
ulong 换成long 试一下
[/Quote]
更换后还是一样!!!
a954105626 2012-10-13
  • 打赏
  • 举报
回复
ulong换成LongLong
小月云 2012-10-13
  • 打赏
  • 举报
回复
请问a954105626哪里有问题?
a954105626 2012-10-13
  • 打赏
  • 举报
回复
你结构体里long型 都换成Integer
ulong 换成long 试一下
a954105626 2012-10-13
  • 打赏
  • 举报
回复
我感觉是你结构体的格式不对
小月云 2012-10-13
  • 打赏
  • 举报
回复
急!!!!在线等!!!
小月云 2012-10-13
  • 打赏
  • 举报
回复
各位大侠,有没有人遇到?
小月云 2012-10-13
  • 打赏
  • 举报
回复
加我QQ:52018042,我发DLL给你帮我看看,谢谢!!!
a954105626 2012-10-13
  • 打赏
  • 举报
回复


--我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是我在网上自己下的

小月云 2012-10-13
  • 打赏
  • 举报
回复
[Quote=引用 11 楼 的回复:]
我刚打开电脑我试一下
[/Quote]
谢谢!

680

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder API 调用
社区管理员
  • API 调用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧