unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure ExitWindowsNT(uFlags : integer);
var
hToken : THANDLE;
tkp, tkDumb : TTokenPrivileges;
DumbInt : DWORD;
begin
FillChar(tkp, sizeof(tkp), 0);
if not (OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES
or TOKEN_QUERY, hToken)) then
raise Exception.create('OpenProcessToken failed with code '+ inttostr(GetLastError)); LookupPrivilegeValue(nil, pchar('SeShutdownPrivilege'),
tkp.Privileges[0].Luid); tkp.PrivilegeCount := 1;
tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, false, tkp, sizeof(tkDumb), tkDumb, DumbInt); if GetLastError <> ERROR_SUCCESS then
Raise Exception.create('AdjustTokenPrivileges failed with code '+ inttostr(GetLastError)); if not ExitWindowsEx(uFlags, 0) then
Raise Exception.create('ExitWindowsEx failed with code '+ inttostr(GetLastError));end;procedure TForm1.Button1Click(Sender: TObject);
begin
ExitWindowsNT(EWX_SHUTDOWN OR EWX_POWEROFF);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
ExitWindowsNT(EWX_SHUTDOWN OR EWX_REBOOT);
end;procedure TForm1.Button3Click(Sender: TObject);
begin
ExitWindowsEX(EWX_SHUTDOWN OR EWX_LOGOFF,0);
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
if strtodate(edit1.Text)=date then button1.OnClick(sender);
end;end.
上面是我做的小关机程序,想让时间器响应EDIT的时间作出动作。
谢谢
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Timer1: TTimer;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}procedure ExitWindowsNT(uFlags : integer);
var
hToken : THANDLE;
tkp, tkDumb : TTokenPrivileges;
DumbInt : DWORD;
begin
FillChar(tkp, sizeof(tkp), 0);
if not (OpenProcessToken(GetCurrentProcess, TOKEN_ADJUST_PRIVILEGES
or TOKEN_QUERY, hToken)) then
raise Exception.create('OpenProcessToken failed with code '+ inttostr(GetLastError)); LookupPrivilegeValue(nil, pchar('SeShutdownPrivilege'),
tkp.Privileges[0].Luid); tkp.PrivilegeCount := 1;
tkp.Privileges[0].Attributes := SE_PRIVILEGE_ENABLED; AdjustTokenPrivileges(hToken, false, tkp, sizeof(tkDumb), tkDumb, DumbInt); if GetLastError <> ERROR_SUCCESS then
Raise Exception.create('AdjustTokenPrivileges failed with code '+ inttostr(GetLastError)); if not ExitWindowsEx(uFlags, 0) then
Raise Exception.create('ExitWindowsEx failed with code '+ inttostr(GetLastError));end;procedure TForm1.Button1Click(Sender: TObject);
begin
ExitWindowsNT(EWX_SHUTDOWN OR EWX_POWEROFF);
end;procedure TForm1.Button2Click(Sender: TObject);
begin
ExitWindowsNT(EWX_SHUTDOWN OR EWX_REBOOT);
end;procedure TForm1.Button3Click(Sender: TObject);
begin
ExitWindowsEX(EWX_SHUTDOWN OR EWX_LOGOFF,0);
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
if strtodate(edit1.Text)=date then button1.OnClick(sender);
end;end.
上面是我做的小关机程序,想让时间器响应EDIT的时间作出动作。
谢谢
解决方案 »
- 求QR code生成 dephi代码
- b m p 数 据 最 小 空 间 保 存 。
- 如何编程判断一个IP地址是否属于某个网段?
- 使用indy的FTP组件上传文件,如何得到上传的文件的大小?
- 一个需要思考的问题!关于StringGrid和ComboBox
- *.tif是什么类型文件,用什么打开?(不是tiff)急 急 急、1
- dcom中怎样返回图象????一定给高分
- 请问:为何我的程序重新编译,老是要提示"无法编译project1.exe",而且它的确仍然驻留在内存里.请指教
- 企业用户需修改“销售清单”格式,高价请delphi高手修改
- Win2k与98的区别?
- 为什么3ds模型加载不上了?
- 关于时间求和的问题请教!
不包含日期的procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Now()>=StrToTime(Edit1.Text) then button1.OnClick(sender);
end;包含日期
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if Now()>=StrToDateTime(Edit1.Text) then button1.OnClick(sender);
end;
i:word;i:=20;
case i of
1://
2://
3..8://end
var
i: integer;
begin
for i:=0 to ComponentCount-1 do //枚举
begin
if Components[i] is TRadioButton then //检查
begin
if ((Edit1.Text=('')) or (TRadioButton(Components[i]).Checked=False)) then
showmessage('没有选定对象或时间有误')
else
begin
if (TRadioButton(Components[i]).Checked=True) then
TRadioButton(Components[i]).OnClick(sender);
button1.Enabled := False;
button1.Caption :='已开始执行任务';
end;
end;
end;
end;因我已经定义了 i 我的意思是如果EDIT框为空和RadioButton未被选中成立就弹出消息。并停止跳出语句
如果两者不成立就执行下一行语言。我很菜的刚学,不要怪我。
up
up
up
up
up
up
up
up
up
up
up
up
up