1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| procedure TForm1.b_set_timeClick(Sender: TObject);
var
res3, i: integer;
temp_time: String;
t_now: TDateTime;
pSetTime: PAnsiChar;
SetTime: array[1..15] of AnsiChar;
t_year, t_month, t_day, t_dayw, t_hour, t_min, t_sec: String;
myYear, myMonth, myDay, myHour, myMin, mySec, myMilli: word;
begin
device_open();
t_now := now;
DecodeDateTime(t_now, myYear, myMonth, myDay, myHour, myMin, mySec, myMilli);
t_year := IntToHex(myYear-2000, 2);
t_month := IntToHex(myMonth, 2);
t_day := IntToHex(myDay, 2);
t_dayw := IntToHex(DayOfTheWeek(t_now), 2);
t_hour := IntToHex(myHour, 2);
t_min := IntToHex(myMin, 2);
t_sec := IntToHex(mySec, 2);
temp_time := PAnsiChar(concat(t_year, t_month, t_day, t_dayw, t_hour, t_min, t_sec));
for i := 1 to 14 do
begin
SetTime[i] := temp_time[i];
end;
SetTime[15] := #0;
pSetTime := addr(SetTime[1]);
res3 := WriteTime(dev_address, pSetTime);
CloseCommPort(hCom);
end; |
Partager