我想设置一个定时器,每阁一个小时就响应一次打印机打印事件,大侠们教教我吧,菜鸟!

解决方案 »

  1.   

    system页面下timer把interval属性设为3600000
      

  2.   

    我想用TTimer中的OnTime()实现,
    procedure TNPForm.TimerTimer(Sender: TObject);
    beginend;可我查了很多程序,知道中间有个Interval,可它是控制毫秒级的,最大也只有64秒多,怎么办?
      

  3.   

    如果是这样的话,你可以加60个timer来实现,对每个timer把interval都设成60000,即一分钟
    用循环来控制,timer1到了把其enable 置为false,同时timer2开启,如此,直到timer60开启时
    执行你的打印,打印完毕后开启又timer1.
    这是可行的,你试试吧。
      

  4.   

    用Timer是可以解决,不过要看你的具体程序,因为Timer的优先级较低,在某些任务中不一定能够得到响应
      

  5.   

    我只想用一个Timer实现,网上有中程序,是可以设置自动关机的,它就只用了一个Timer,可我看他的TimerTime()我却怎么也看不出来他是如何通过到这个点就响应的。
      

  6.   

    同志你怎么走了死胡同了呢?
    你可以在timer的ontime事件中调用now()函数,然后记住上一次响应时间,然后与现在世界求diff到一个小时后就调用打印机事件啊!
      

  7.   

    自动关机我写过,每隔一秒钟判断系统时间跟设定时间是否一致就行了Interval最大也只有64秒多么?不是吧,它的类型是Integer的,从-2^63到2^63,你需要一小时,设成3600000,肯定可以
      

  8.   

    用windows API 。
    Unit
    Windows.PasSyntax
    GetTickCount: DWORD; {returns a 32 bit number}
    //函数
    Description
    This function returns the number of milliseconds that have elapsed since Windows was started. Since this time is stored in a DWORD, it will wrap to zero if Windows is left in operation for 49.7 days. Under Windows NT, the application can obtain the elapsed time since Windows was started by finding the System Up Time counter in performance data under the HKEY_PERFORMANCE_DATA registry key. This value will be an 8 byte number.Return Values
    If the function succeeds, the return value is the number of milliseconds that have elapsed since Windows was started; otherwise it returns zero.
    for example:
    procedure TForm1.Button1Click(Sender: TObject);
    var
      Tick: DWORD;    // holds the number of milliseconds
    begin
      {get the number of milliseconds since Windows was started}
      Tick:= GetTickCount;  {display the number of milliseconds}
      Label1.Caption:= 'Number of Milliseconds: ' + IntToStr(Tick);
    end;你可以写一个线程,在线程中计数判断是否过了一个小时,若符合条件则执行打印过程,执行完后重起线程就行了。