这个课题有点新意:做一个单独工程文件dpr里的定时器(10分)

  • 主题发起人 主题发起人 天空还下着沙
  • 开始时间 开始时间

天空还下着沙

Unregistered / Unconfirmed
GUEST, unregistred user!
这个课题有点新意:做一个单独工程文件dpr里的定时器<br><br>因为想在服务器端运行个小程序,所以,不需要任何窗口等界面元素,也不响应任何用户消息<br><br>就是要在服务器后台,每1小时写一条记录到数据库,用ADO联。<br><br>哪位能给我写一个这样的东东??谢谢<br><br>用Timer或winapi函数都行<br><br>=&gt;&gt; 请回复到非技术区,有200分
 
是API,如果你不Create Timer的话。单独Create Timer不知道是否可以,应该也可以。<br>一会俺试验一下。<br><br>{<br>&nbsp; The timeSetEvent function starts a specified timer event.<br>&nbsp; The multimedia timer runs in its own thread. After the event is activated,<br>&nbsp; it calls the specified callback function or sets or pulses the spe<br>&nbsp; cified event object.<br><br>&nbsp; MMRESULT timeSetEvent(<br>&nbsp; UINT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uDelay,<br>&nbsp; UINT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; uResolution,<br>&nbsp; LPTIMECALLBACK lpTimeProc,<br>&nbsp; DWORD_PTR &nbsp; &nbsp; &nbsp;dwUser,<br>&nbsp; UINT &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fuEvent<br>&nbsp; );<br><br>&nbsp; uDelay:<br>&nbsp; &nbsp;Event delay, in milliseconds<br><br>&nbsp; uResolution:<br>&nbsp; &nbsp;Resolution of the timer event, in milliseconds.<br>&nbsp; &nbsp;A resolution of 0 indicates periodic events should occur with the<br>&nbsp; &nbsp;greatest possible accuracy.<br>&nbsp; &nbsp;You should use the use the maximum value appropriate to reduce system overhead.<br><br>&nbsp; fuEvent:<br>&nbsp; &nbsp;TIME_ONESHOT Event occurs once, after uDelay milliseconds.<br>&nbsp; &nbsp;TIME_PERIODIC Event occurs every uDelay milliseconds.<br>}<br>uses<br>&nbsp; MMSystem;<br><br>var<br>&nbsp; mmResult: Integer;<br><br>{回调函数}<br>procedure TimeCallBack(TimerID, Msg: Uint; dwUser, dw1, dw2: DWORD); pascal;<br>begin<br>&nbsp; // Do something here. This procedure will be executed each 10 ms<br>&nbsp; Form1.Label1.Caption := Form1.Label1.Caption + '%';<br>end;<br><br>// Set a new timer with a delay of 10 ms<br>procedure TForm1.Button1Click(Sender: TObject);<br>begin<br>&nbsp; mmResult := TimeSetEvent(10, 0, @TimeCallBack, 0, TIME_PERIODIC);<br>end;<br><br>{退出的时候,取消事件}<br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br>&nbsp; TimeKillEvent(mmResult);<br>end;
 
当然,你需要将上面代码改成控制台程序了。
 
我觉得可以建立一个服务,问题就可以解决了的。
 
用datamoudle不就可以了
 
接受答案了.
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
D
回复
0
查看
2K
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部