主要代码如下:var
  Form1: TForm1;
  inifile:tinifile;
  tssj:integer;//读取保存在ini文件中的关机提示时间
  gjsj:ttime;//读取保存在ini文件中的关机时间implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
begin
  inifile:=tinifile.Create('./setup.ini');
  inifile.WriteInteger('关机提示','提示时间',strtoint(edit1.Text));
  inifile.WriteTime('关机时间','时间',datetimepicker1.Time);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
  tssj:=inifile.ReadInteger('关机提示','提示时间', 0);
  gjsj:=inifile.ReadTime('关机时间','时间',time);
  timer1.Enabled:=true;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if (SecondsBetween(gjsj,now)=tssj) then
      begin
        Timer1.Enabled:=false;
        ShowMessage('电脑将在'+IntToStr(tssj)+'秒后关机!');//弹出提示
        exit;
      end;
end;
注:程序的本意是通过edit输入一个整数,这个整数即是关机前弹出提示的时间。现在问题是时间到了却没有弹出提示,请帮助我找出错误所在。

解决方案 »

  1.   

    关键你要检查 if (SecondsBetween(gjsj,now)=tssj) then 这个条件满足吗,你跟踪一下
      

  2.   

    感谢楼上兄弟的回答,SecondsBetween(gjsj,now)=tssj这个条件确实无法满足。
    您好人做到底,请问我怎么才能达到我的目的呢?
      

  3.   

    把 if (SecondsBetween(gjsj,now)=tssj) then 中的now换成time能够弹出提示了,但是弹出的时间不是十分精确......
      

  4.   

    你的Timer必须设置为1秒一次,否则很容易错过tssj的值,就是说:当时钟控件运行n次后,只比tssj小一点,但下一个Timer来的时候,已经比tssj大了,正好错过了。所以不等。
      

  5.   

    用timer会因为系统繁忙而导致时间不准确。你的提示最好用需要响应的。