📄 unit2.pas
字号:
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm2 = class(TForm)
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Memo1: TMemo;
Button1: TButton;
Timer1: TTimer;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Button2: TButton;
Label4: TLabel;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form2: TForm2;
flg:bool=false;
implementation
{$R *.dfm}
procedure TForm2.Timer1Timer(Sender: TObject);
var
inputtime:string;
systemtime:string;
i:integer;
begin
edit1.Text:=datetimetostr(date+time);
if flg=true then //flg是,是否按下”设定“按钮的标志
begin
inputtime:=edit2.Text+':'+edit3.Text;
systemtime:=FormatDateTime('hh:mm',time);
//处理好时间字符串格式,以便相比较
if inputtime=systemtime then
begin
memo1.Lines.Add('定时时间到了');
if radiobutton3.Checked=true then //如果选中了radiobutton3 则定时注销
ExitWindowsEx(EWX_LOGOFF,0);
if radiobutton1.Checked=true then //如果选中了radiobutton1 则定时关机
ExitWindowsEx(EWX_SHUTDOWN,0);
if radiobutton2.Checked=true then //如果选中了radiobutton2 则定时重新启动
ExitWindowsEx(EWX_REBOOT,0);
if radiobutton4.Checked=true then //如果选中了radiobutton4则定时动”记事本“
WinExec('C:\WINDOWS\NOTEPAD.exe',1);
for i:=1 to 5 do //发出5声声音报警
begin
beep; //发出声音
sleep(500);//(每声延时500毫秒);
end;
flg:=false; //报警任务完成,需恢复标志的值
end;
end;
end;
procedure TForm2.Button1Click(Sender: TObject);
begin
flg:=true;
memo1.Lines.Clear;
memo1.Lines.Add('当前设定的时间是:'+edit2.Text+':'+edit3.Text);
end;
procedure TForm2.Button2Click(Sender: TObject);
begin
flg:=false;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -