Private Declare Function senddata Lib "standcom.dll" _
(ByVal comlen As Long, ByRef com As Byte, ByVal leng As Long, ByRef data As Byte, ByRef device As Byte) As Long
Private Declare Function getdata Lib "standcom.dll" _
(ByVal comlen As Long, ByRef com As Byte, ByVal leng As Long, ByRef data As Byte, ByRef device As Byte) As Long就是这个代码
(ByVal comlen As Long, ByRef com As Byte, ByVal leng As Long, ByRef data As Byte, ByRef device As Byte) As Long
Private Declare Function getdata Lib "standcom.dll" _
(ByVal comlen As Long, ByRef com As Byte, ByVal leng As Long, ByRef data As Byte, ByRef device As Byte) As Long就是这个代码
解决方案 »
- 请教,我该如何建立这样的系统?
- idudpserver接收数据时会丢失一些数据包怎么办?
- 如何制作类QQ的好友列表功能
- 1.用QUERY插入、更新一条记录时,怎样对一些字段进行约束,比如不允许为空的字段,用存储过程能做到吗?怎样写?
- 请问:如果实现像FlashGet那样的字符信息滚动显示?TStringGrid好像不行。
- 在adoquery中,每当指向记录的指针发生变化时就触发某事件的代码该如何写
- 一个非常着急的问题,很容易的问题
- 怎样编程实现在没安装acrobat reader的机器上正常打开pdf文件?
- 请问,我要在一个没有form的unit里调用图标资源应该怎样做?
- 新建一个桌面后,如何移动已经运行的进程的窗体和右下角的图标到新的桌面上显示
- 怎样让窗口不被摭挡!??
- 初学三层开发,ClientDataSet在进行数据操作时,如何进行事务操作
function senddata(const comlen:LongInt;var com:Byte;leng:LongInt;data:Byte;device:Byte):LongInt;stdcall;External'standcom.dll';
function getdata(comlen:LongInt;com:Byte;leng :LongInt; data : Byte; device: Byte):LongInt;stdcall;External'standcom.dll'; //////////
我这样写,没有看到错误,但是
procedure TForm1.Timer1Timer(Sender: TObject);
var
sendatalen:LongInt;
gdata:array [0..20] of Byte;
sdata:array [0..20] of Byte;
gdata1:array [0..10] of Byte;
device:array [0..11] of Byte;
Command:array [0..10] of Byte;
tempno:LongInt;
tkh,tempcom,tempname,templeibi,tempstno:string;
txfje:Double;
intmoney:LongInt;
longg,commandLen,ret,temp,temp1:integer;
kh2,kh1,kh3,kh4,kh5,kh6,senddatalen:LongInt;
rem3:double;
begin
tempno:= strtoint(Trim(Edit1.Text));
tempcom:= Trim(Edit2.Text);
// tkh = Trim(Text5.Text)
commandLen:= 4;
longg := 9;
Command[0]:= tempno;
Command[1]:= 167;
Command[2]:= 9;
Command[3]:= 0;
Command[4]:= 0;
device[0]:= ord('C');
device[1]:= ord('O');
device[2]:= ord('M');
device[3]:= ord('1');
// online:=getdata(commandLen,pchar(Command),gdataLen, pchar(gdata),pchar(device)) ; ret:= getdata(commandLen, Command[0], longg, gdata[0], device[0]);
If ret <> 0 Then //在不在网上
Label1.Caption:= '不在网上'
Else
begin
temp:= gdata[0];
temp1:= gdata[1];
If temp1 = 167 Then //在网上
Label1.Caption:= '在网上'; If temp1 = 168 Then //断定卡号,及卡上的余额
begin
kh1:= gdata[2]; //消费模式3
kh2:=gdata[3];
kh3:=gdata[4];
kh4:=gdata[5];
kh5:=gdata[6];
kh6:=gdata[7];
commandLen:=4;
senddatalen:=7;
Command[0]:= tempno;
Command[1]:= 168;
Command[2]:= 7;
Command[3]:= 0;
Command[4]:= 0;
sdata[0]:= kh1;
sdata[1]:= kh2;
sdata[2]:= kh3;
sdata[3]:= kh4;
rem3:= kh2 * 256 + kh3 + kh1 * 65536;
edit3.Text:= floattostr(rem3);
end;
end;end;
这样调用就出错误了
project project1.exe raised exception class eaccessviolation
with message "access violation at address 1000102A in moudle'
"standcom.dll.read of address 00000002'
process stopped use step or run to continue
to Arvin2003(梅园先生)
这个是人家的设备,做二次开发,人家提供的部分代码
function senddata(comlen:longint;com:PChar;leng:longint;data,device:PChar):longint;stdcall;external'standCOM.DLL';
////////////procedure TForm1.Timer2Timer(Sender: TObject);
var
sendatalen:LongInt;
gdata:array [0..20] of Byte;
sdata:array [0..20] of Byte;
gdata1:array [0..10] of Byte;
device:array [0..11] of Byte;
Command:array [0..10] of Byte;
tempno:LongInt;
tkh,tempcom,tempname,templeibi,tempstno:string;
txfje:Double;
intmoney:LongInt;
longg,commandLen,ret,temp,temp1:integer;
kh2,kh1,kh3,kh4,kh5,kh6,senddatalen:LongInt;
rem3:double;
begin
tempno:= strtoint(Trim(Edit1.Text));
tempcom:= Trim(Edit2.Text);
// tkh = Trim(Text5.Text)
commandLen:= 4;
longg := 9;
Command[0]:= tempno;
Command[1]:= 167;
Command[2]:= 9;
Command[3]:= 0;
Command[4]:= 0;
device[0]:= ord('C');
device[1]:= ord('O');
device[2]:= ord('M');
device[3]:= ord('1');
// online:=getdata(commandLen,pchar(Command),gdataLen, pchar(gdata),pchar(device)) ;
ret:=getdata(commandLen,@Command[0],longg,@gdata[0],@device[0]);
// ret:= getdata(commandLen, Command[0], longg, gdata[0], device[0]);
Label2.Caption:=inttostr(ret);
If ret <> 0 Then //在不在网上
Label1.Caption:= '不在网上'
Else
begin
// temp:= gdata[0];
temp1:= gdata[1];
Label3.Caption:=inttostr(temp1);
If temp1 = 167 Then //在网上
Label1.Caption:= '在网上'; If temp1 = 168 Then //断定卡号,及卡上的余额
begin
kh1:= gdata[2]; //消费模式3
kh2:=gdata[3];
kh3:=gdata[4];
rem3:= kh2 * 256 + kh3 + kh1 * 65536;
edit3.Text:= floattostr(rem3);
end;
end;end;