定时关机程序调用什么函数?(50分)

  • 主题发起人 主题发起人 萧君
  • 开始时间 开始时间

萧君

Unregistered / Unconfirmed
GUEST, unregistred user!
想写一个定时关机程序,怎么写?最好有源代码!
 
加入一个Timer控件,<br>然后在其中写代码。<br>你一定能成功。
 
if datetimetostr(now)=你所定时间 then<br>&nbsp;ExitWindowsEx(EWX_SHUTDOWN and EWX_POWEROFF ,1);
 
关机的很简单啊,放定时器,定时器的时间间隔设为可调就可以了。如果要你做一个定时<br>开机的你就麻烦了。呵呵
 
NT和2000下执行 ExitWindowsEx要有关机全县。<br>调整权限令牌得函数你搜一下旧贴子就有了。<br><br>如果关电源得话,电源要ATX的。
 
majorsoft的方法就可以了!<br>调用<br>&nbsp;ExitWindowsEx 函数就行了!
 
用ExitWindowsEx函数,你可以看看帮助,非常简单(NT出外)
 
楼上都可以的。<br>如果不符合你的要求,就把你的用途说明白。
 
放入一Timer控件,先获取系统时间,再在Timer中设定关机时间。<br>
 
嘿嘿,如果在window nt/2000下可不是那么简单。给你一坨:<br>unit Unit1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br>&nbsp; Dialogs, StdCtrls, TlHelp32, ImgList, ExtCtrls, jpeg;<br><br>type<br>&nbsp; TForm1 = class(TForm)<br>&nbsp; &nbsp; Timer1: TTimer;<br>&nbsp; &nbsp; Image2: TImage;<br>&nbsp; &nbsp; Panel1: TPanel;<br>&nbsp; &nbsp; ListBox1: TListBox;<br>&nbsp; &nbsp; Panel2: TPanel;<br>&nbsp; &nbsp; procedure FormCreate(Sender: TObject);<br>&nbsp; &nbsp; procedure Timer1Timer(Sender: TObject);<br>&nbsp; &nbsp; procedure Image2DblClick(Sender: TObject);<br>&nbsp; &nbsp; procedure FormShow(Sender: TObject);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>&nbsp; var lppe:TProcessEntry32;<br>&nbsp; &nbsp; &nbsp; found:boolean;<br>&nbsp; &nbsp; &nbsp; hand:THandle;<br>begin<br>&nbsp; Hand:=CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);<br>&nbsp; found:=Process32First(Hand,lppe);<br>&nbsp; while found do<br>&nbsp; begin<br>&nbsp; &nbsp; ListBox1.Items.Add(lppe.szExeFile);<br>&nbsp; &nbsp; found:=Process32Next(Hand,lppe);<br>&nbsp; end;<br>end;<br><br>procedure TForm1.Timer1Timer(Sender: TObject);<br>&nbsp; var lppe:TProcessEntry32;<br>&nbsp; &nbsp; &nbsp; found:boolean;<br>&nbsp; &nbsp; &nbsp; hand:THandle;<br>begin<br>&nbsp; ListBox1.Clear;<br>&nbsp; Hand:=CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);<br>&nbsp; found:=Process32First(Hand,lppe);<br>&nbsp; while found do<br>&nbsp; begin<br>&nbsp; &nbsp; ListBox1.items.Add(' &nbsp; &nbsp; '+strpas(lppe.szExeFile));<br>&nbsp; &nbsp; found:=Process32Next(hand,lppe);<br>&nbsp; end;<br>end;<br><br>procedure TForm1.Image2DblClick(Sender: TObject);<br>begin<br>&nbsp; Close;<br>end;<br><br>procedure TForm1.FormShow(Sender: TObject);<br>begin<br>&nbsp; Form1.BringToFront;<br>end;<br><br>end.
 
对不起,对不起发错了。(我的硬盘太乱,自打一把掌!!!!!)
 
加入一个Timer控件,随时监控系统时间<br>如果到了关机时间,就<br>ExitWindowsEx(EWX_SHUTDOWN,0)
 
//关闭2000或NT先取行关闭的权限,要不要获行版本的函数,<br>以便在98下直接用ExitWindowsEx(EWX_FORCE OR EWX_SHUTDOWN OR EWX_POWEROFF,0);<br>procedure TFrmShutDown.BeginShutDown;<br>var<br>&nbsp; CurrHdl,<br>&nbsp; TakeHdl: THandle;<br>&nbsp; Uid: TLargeInteger;<br>&nbsp; Tkp,<br>&nbsp; TkpPrvs: TTokenPrivileges;<br>&nbsp; ReturnL: DWord;<br>begin<br>&nbsp; CurrHdl:=GetCurrentProcess;<br>&nbsp; OpenProcessToken(CurrHdl,(TOKEN_ADJUST_PRIVILEGES OR TOKEN_QUERY),TakeHdl);<br>&nbsp; LookUpPrivilegeValue(nil,PChar('SeShutdownPrivilege'),Uid);<br>&nbsp; Tkp.PrivilegeCount:=1;<br>&nbsp; Tkp.Privileges[0].Luid:=Uid;<br>&nbsp; Tkp.Privileges[0].Attributes:=SE_PRIVILEGE_ENABLED;<br>&nbsp; AdjustTokenPrivileges(TakeHdl,False,Tkp,SizeOf(TkpPrvs),TkpPrvs,ReturnL);<br><br>&nbsp; ExitWindowsEx(EWX_FORCE OR EWX_SHUTDOWN OR EWX_POWEROFF,0);<br>end;<br><br>procedure TFrmShutDown.TmShutDownTimer(Sender: TObject);<br>begin<br>&nbsp; BeginShutDown;<br>end;<br>
 
即然來晚了,怎樣操作大家都說了,那我就給你一個槓架模型吧!<br>我以前自已做有的,在http://delphigame.vip.idv.tw/中遊戲下載中有下載,你看看吧!<br>不過那過以經落后了,現在正在正新更好的!那個有點不穩定,相信很快在那個提供下載的地<br>方又有新版本可提供下載了!<br>新的版本所以的地方都提供英文版,現在下載的Help不提供!<br>敬請關注!
 
后退
顶部