用delphi,调用一卡通的读卡函数,总是出错,请大家帮我看看吧
C++定义:
原型:ReadUid_cst(int& szCardType ,unsigned char* szData)
输入参数:无
输出参数:szCardType:卡类型,1:13.56,2:2.4
szData:UID
返回值:成功返回1,
typedef struct _USERDATA_MM1
{
char szName[14]; //姓名
unsigned char nSex; //性别
unsigned char nCertType; //证件类型
char szCertCode[20]; //证件号
unsigned char bzMobile[6]; //手机号码
unsigned int nCardSn; //卡序号
char szUserID[10]; //工号
unsigned char nCardType; //卡类型
unsigned char nDayCountLimit; //日限次数
unsigned int nDayMoneyLimit; //日限金额
char szDept[12]; //部门
unsigned char bzUserPsw[3]; //用户密钥
unsigned char bzStartDate[4]; //开始时间
unsigned char bzExpiryDate[4]; //有效期限
unsigned short wLssj; //流水号
unsigned int nBalance; //预充余额(分),读取信息时为卡余额
}USERDATA_MM1, *LPUSERDATA_MM1;
delphi xe3 的程序代码:
Type
PUCard = ^Ucard;
Ucard = packed record
szName : array[0..13] of Byte; //姓名
nSex : Byte; //性别
nCertType : Byte; //证件类型
szCertCode : array[0..19] of Byte; //证件号
bzMobile : array[0..5] of byte; //手机号码
nCardSn : Word; //卡序号
szUserID : array[0..9] of Byte; //工号
nCardType : Byte; //卡类别
nDayCountLimit : Byte; //日限次数
nDayMoneyLimit : Word; //日限金额
szDept : array[0..11] of Byte; //部门
bzUserPsw : array[0..2] of byte; //用户密钥
bzStartDate : array[0..3] of byte; //开始时间
bzExpriyDate : array[0..3] of byte; //有效期限
wLssj : Word; //流水号
nbalance : Word; //预充余额(分),读取信息时为卡余额
end;
function ReadUid_cst(var szCardType:Word; szData:PUCard):Int16;stdcall; //cdecl
external 'cstcard.dll' name 'ReadUid_cst';
procedure TForm1.btn1Click(Sender: TObject);
var
szCardType : Word;
szData : Ucard;
psz : PUCard;
tmp : string;
rcode : Int16;
begin
psz:= @szdata;
rcode := ReadUid_cst(szCardType,psz);
Self.Caption := IntToStr(rcode);
//tmp := PAnsiChar(@szdata.szCertCode);
//Self.lbl1.Caption := tmp;
end;
该回答引用ChatGPT-3.5
你提供的信息很有限,无法确定问题的确切原因。但根据你提供的信息,这个错误可能是由以下原因导致的:
为了解决这个问题,你可以尝试以下方法:
希望这些建议能帮助你解决问题。