📄 unit1.pas
字号:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Button1: TButton;
memo1: TMemo;
Button2: TButton;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
function CH375ReadData(index:dword; ibuff:pointer; var len:dword):longbool;stdcall;external'CH375DLL.DLL';
function CH375WriteData( index:dword; ibuff:pointer; var len:dword):longbool;stdcall;external'CH375DLL.DLL';
function CH375OpenDevice(index:dword):integer;stdcall;external'CH375DLL.DLL';
function CH375CloseDevice(index:dword):integer;stdcall;external'CH375DLL.DLL';
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
if CH375OpenDevice(0)=-1 then
showmessage('不能打开USB')
else
form1.Caption:='USB已经打开';
end;
const
index:dword=0;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
s:string;
mDemoReq,rbuf:array[1..64] of byte;
mLength:dword;
len:dword;
begin
len:=64;
s:=edit1.Text+chr(10);
mLength:=length(s);
For i:=1 To mLength do
begin
mDemoReq[i]:=ord(s[i]);
end;
CH375WriteData(index,@mDemoReq,mlength);
edit1.Text:='';
CH375ReadData(0,@rbuf,len);
// for i:=1 to 63 do
//edit2.Text:=edit2.Text+chr(rbuf[i]);
//edit2.Text:=strpas(@rbuf);
memo1.Lines.Add(strpas(@rbuf));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
memo1.Clear;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -