应该人家都有说明书和DEMO的,以前弄高速公路收费系统的时候一安装驱动就有DEMO了。修改DEMO就可以使用了。下面随便贴段代码,参考一下: procedure TForm3.Timer1Timer(Sender: TObject); var buf,inputstring:string; dotpos:integer; x:integer; begin try x:=1; i:=i+1; inputstring:='#'+'02'+chr(13); Mscomm1.Output:=inputstring; sleep(150); buf:=trim(Mscomm1.Input); buf:='+0.3200+0.4400+0.5600+0.6700+0.7800'; if buf='' then begin timer1.Enabled:=false; showmessage('取值失败!'); exit; end; if pos('.',buf)<1 then begin timer1.enabled:=false; showmessage('返回的数据错误!请重新采集.'); exit; end else begin dotpos:=pos('.',buf); a[i]:=strtofloat(copy(buf,dotpos-1,6)); buf:=copy(buf,dotpos+4,length(buf)-7); dotpos:=pos('.',buf); b[i]:=strtofloat(copy(buf,dotpos-1,6)); buf:=copy(buf,dotpos+4,length(buf)-7); dotpos:=pos('.',buf); c[i]:=strtofloat(copy(buf,dotpos-1,6)); buf:=copy(buf,dotpos+4,length(buf)-7); dotpos:=pos('.',buf); d[i]:=strtofloat(copy(buf,dotpos-1,6)); buf:=copy(buf,dotpos+4,length(buf)-7); dotpos:=pos('.',buf); e[i]:=strtofloat(copy(buf,dotpos-1,6)); with paintbox1.Canvas do begin pen.Width:=2; if flag1=1 then begin edit1.Text:=floattostr(a[i]); pen.Color:=clred; moveto((i-1),400-trunc(400*a[i-1])); lineto(i,400-trunc(400*a[i])); end; if flag2=1 then begin edit2.Text:=floattostr(b[i]); pen.Color:=clmaroon; moveto((i-1),400-trunc(400*b[i-1])); lineto(i,400-trunc(400*b[i])); end; if flag3=1 then begin edit3.Text:=floattostr(c[i]); pen.Color:=clpurple; moveto((i-1),400-trunc(400*c[i-1])); lineto(i,400-trunc(400*c[i])); end; if flag4=1 then begin edit4.Text:=floattostr(d[i]); pen.Color:=cllime; moveto((i-1),400-trunc(400*d[i-1])); lineto(i,400-trunc(400*d[i])); end; if flag5=1 then begin edit5.Text:=floattostr(e[i]); pen.Color:=clblue; moveto((i-1),400-trunc(400*e[i-1])); lineto(i,400-trunc(400*e[i])); end; end; end; except showmessage('rong'); timer1.enabled:=false; end; end;
procedure TForm3.Timer1Timer(Sender: TObject);
var
buf,inputstring:string;
dotpos:integer;
x:integer;
begin
try
x:=1;
i:=i+1;
inputstring:='#'+'02'+chr(13);
Mscomm1.Output:=inputstring;
sleep(150);
buf:=trim(Mscomm1.Input);
buf:='+0.3200+0.4400+0.5600+0.6700+0.7800';
if buf='' then
begin
timer1.Enabled:=false;
showmessage('取值失败!');
exit;
end;
if pos('.',buf)<1 then
begin
timer1.enabled:=false;
showmessage('返回的数据错误!请重新采集.'); exit; end
else
begin
dotpos:=pos('.',buf);
a[i]:=strtofloat(copy(buf,dotpos-1,6));
buf:=copy(buf,dotpos+4,length(buf)-7);
dotpos:=pos('.',buf);
b[i]:=strtofloat(copy(buf,dotpos-1,6));
buf:=copy(buf,dotpos+4,length(buf)-7);
dotpos:=pos('.',buf);
c[i]:=strtofloat(copy(buf,dotpos-1,6));
buf:=copy(buf,dotpos+4,length(buf)-7);
dotpos:=pos('.',buf);
d[i]:=strtofloat(copy(buf,dotpos-1,6));
buf:=copy(buf,dotpos+4,length(buf)-7);
dotpos:=pos('.',buf);
e[i]:=strtofloat(copy(buf,dotpos-1,6));
with paintbox1.Canvas do
begin
pen.Width:=2;
if flag1=1 then
begin
edit1.Text:=floattostr(a[i]);
pen.Color:=clred;
moveto((i-1),400-trunc(400*a[i-1]));
lineto(i,400-trunc(400*a[i]));
end;
if flag2=1 then
begin
edit2.Text:=floattostr(b[i]);
pen.Color:=clmaroon;
moveto((i-1),400-trunc(400*b[i-1]));
lineto(i,400-trunc(400*b[i]));
end;
if flag3=1 then
begin
edit3.Text:=floattostr(c[i]);
pen.Color:=clpurple;
moveto((i-1),400-trunc(400*c[i-1]));
lineto(i,400-trunc(400*c[i]));
end;
if flag4=1 then
begin
edit4.Text:=floattostr(d[i]);
pen.Color:=cllime;
moveto((i-1),400-trunc(400*d[i-1]));
lineto(i,400-trunc(400*d[i]));
end;
if flag5=1 then
begin
edit5.Text:=floattostr(e[i]);
pen.Color:=clblue;
moveto((i-1),400-trunc(400*e[i-1]));
lineto(i,400-trunc(400*e[i]));
end;
end;
end;
except
showmessage('rong');
timer1.enabled:=false;
end;
end;
有没有什么api访问pci卡?