Var
Ole: Olevariant;
K, h: integer;
Byte1: byte;
S1: string;
The begin
//verify password
According to:=ComboBox7. Text;
Checkdata (according to);
If length (according to) & lt;> 12 then
The begin
Showmessage (' input error, input characters in length and requirements, please check carefully, ');
exit;
end;
Initcomm;
Comm. RThreshold:=0;
If comm. PortOpen=false then
Comm. PortOpen:=true;
Comm. DTREnable:=true;
Comm. RTSEnable:=true;
Ole:=VarArrayCreate ([0, 15], varByte);
Ole [0] :=$4 d;
Ole [1] :=$4 d;
: for k=1 to 12 do
The begin
Ole [k + 1] :=word (according to [k]);
end;
Ole [14] :=$0 d;
For h:=1 to 14 do
The begin
Byte1:=byte1 + ole [h];
end;
S1:=inttohex (byte1 mod. 256, 2);
Ole [15] :=strtoint (' $' + s1);
Comm. Output:=ole;
Sleep (50);
Ole:=Comm. Input;
If ole [0]=$DD then
The begin
The show. The Lines. The Add (' successful ');
Success:=true;
End
Else if ole [0]=$AA then
The show. The Lines. The Add (' fail ')
The else
exit;
end;
If no problem, click this button for the first time for the second consecutive time at the click of a button in the variant array index of error bounds,
CodePudding user response:
http://download.csdn.net/detail/veron_04/1777027