我想在每天一天固定一个时间,
比如说零点,让程序执行一次,
烦劳大家讨论一下该用什么方式实现?
比如说零点,让程序执行一次,
烦劳大家讨论一下该用什么方式实现?
解决方案 »
- 不用勾子,实时监视另一个程序的窗口有没有按回车键
- Indy UDP 广播的回复问题
- delphi怎样获得地址拦中的请求信息
- 如何用API函数或delphi取出当前IE窗口已经选中的文本信息字符串?
- 怎样清空一个字符数组?
- 招聘DELPHI程序员,工作地点:上海
- 前台使用触发器,如何得到该触发器的执行情况呢......
- 200分求购:一段使用TNMSmtp 或者是 Indy9的 TIdSmtp◆能够◆发送邮件的程序???
- 搜了一晚上,但还没找到一个正确的取消共享文件夹的办法?netsharedel需要引用什么?谢谢!
- Fast Report 里面,Count怎么不能用啊?SOS!
- 在installshiled 里如何添加com+组件的安装,卸载程序的时候如何自动卸载com+组件?
- 在installshiled 里如何添加com+组件的安装,卸载程序的时候如何自动卸载com+组件?
使用now获取系统时间
使用decodetime函数转换系统时间的格式进行比较检查。
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Timer1: TTimer;
Edit1: TEdit;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
begin
edit1.text:=FormatDateTime('hh:mm:ss',now());
if edit1.Text='23:16:10' then
begin
showmessage('');
//run ....
end;end;end.
我不建议使用timer控件控件,或是其他的控件,小程序要尽量少用的使用系统资源。
时间测试这方面我还没有好的算法。不过我相信会有高手解决。用系统时间,和起机CPU运行时间。
我的程序里有定时的例子:
procedure Tmain.Timer1Timer(Sender: TObject);
var
i: integer;
begin
for i:= 0 to combobox1.items.count-1 do
if (datetimetostr(time) =combobox1.Items[i]) then
begin
button1.Click ;
end;
end;
是很占资源的
,
我写的一个只有一个窗口的程序就占了2M的内存空间,建议不用窗体