📄 ufrmshutdown.pas
字号:
unit UFrmShutDown;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, cxControls, cxContainer, cxEdit, cxGroupBox, ExtCtrls,
cxLookAndFeelPainters, StdCtrls, cxButtons, cxTextEdit, cxMaskEdit,
cxSpinEdit, cxTimeEdit;
type
TFrmShutDown = class(TForm)
Panel1: TPanel;
cxGroupBox1: TcxGroupBox;
cxButton1: TcxButton;
cxButton2: TcxButton;
edtTime: TcxTimeEdit;
Label1: TLabel;
procedure cxButton2Click(Sender: TObject);
procedure cxButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
FrmShutDown: TFrmShutDown;
implementation
{$R *.dfm}
procedure TFrmShutDown.cxButton2Click(Sender: TObject);
begin
Close;
end;
procedure TFrmShutDown.cxButton1Click(Sender: TObject);
var
s : string;
vList: TStringList;
begin
vList := TStringList.Create;
try
if FileExists(ExtractFilePath(Application.ExeName) + '\Shutdown.bat') then
begin
DeleteFile(ExtractFilePath(Application.ExeName) + '\Shutdown.bat');
s := 'at ' + edtTime.Text + ' shutdown -s';
vList.Clear;
vList.Add(s);
vList.SaveToFile(ExtractFilePath(Application.ExeName) + '\Shutdown.bat');
WinExec(PChar(ExtractFilePath(Application.ExeName) + '\Shutdown.bat'), SW_HIDE);
end
else
begin
// FileCreate(ExtractFilePath(Application.ExeName) + '\Shutdown.bat');
s := 'at ' + edtTime.Text + ' shutdown -s';
vList.Clear;
vList.Add(s);
vList.SaveToFile(ExtractFilePath(Application.ExeName) + '\Shutdown.bat');
WinExec(PChar(ExtractFilePath(Application.ExeName) + '\Shutdown.bat'), SW_HIDE);
end;
finally
vList.Free;
end;
Close;
end;
procedure TFrmShutDown.FormCreate(Sender: TObject);
begin
edtTime.Time := Now;
end;
procedure TFrmShutDown.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
Action := caFree;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -