这是一个完整的例子<br>你只需要改变 time控件的事件里的相关参数就可以了<br><br>unit Unit1;<br><br>interface<br><br>uses<br> Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> Dialogs, StdCtrls, Buttons,TlHelp32, ExtCtrls,DateUtils;<br><br>type<br> ///////////////////////////////<br> TProcessInfo=Record<br> ExeFile:string;<br> ProcessID
word;<br> end;<br> ProcessInfo=^TProcessInfo;//////////<br> TForm1 = class(TForm)<br> Timer1: TTimer;<br> procedure Timer1Timer(Sender: TObject);<br> private<br> { Private declarations }<br> public<br> { Public declarations }<br> end;<br> //////////////////////////////////////////////////////////////////////////////<br> //11.取得当前进程列表<br> //////////////////////////////////////////////////////////////////////////////<br> procedure ProcessList(Var pList:TList);<br> //////////////////////////////////////////////////////////////////////////////<br> //12.终止某一正在运行的进程<br> //////////////////////////////////////////////////////////////////////////////<br> procedure HideProcess(ProcessName:string);<br> /////////////////////////////////////////////////////////////////////////////<br> //13.查找进程<br> //////////////////////////////////////////////////////////////////////////////<br> function FindProcess(ProcessName:string):Bool;<br> ////////////////////////////////////////////////////////////////////////////////<br> //23判断此日期是不是当月最后一天<br> ////////////////////////////////////////////////////////////////////////////////<br> function LastDay(Date1:Tdate):bool;<br>var<br> Form1: TForm1;<br><br>implementation<br><br>{$R *.dfm}<br>//////////////////////////////////////////////////////////////////////////////<br>//11.取得当前进程列表<br>//////////////////////////////////////////////////////////////////////////////<br>procedure ProcessList(Var pList:TList);<br>var p
rocessInfo;<br> ok:Bool;<br> ProcessListHandle:THandle;<br> ProcessStruct:TProcessEntry32;<br>begin<br> pList:=TList.Create;<br> pList.Clear;<br> ProcessListHandle:=CreateToolHelp32SnapShot(TH32cs_SnapProcess,0);<br> ProcessStruct.dwSize:=SizeOf(ProcessStruct);<br> ok:=Process32First(ProcessListHandle,ProcessStruct);<br> while integer(ok)<>0 do<br> begin<br> New(p);<br> p.ExeFile:=ProcessStruct.szExeFile;<br> p.ProcessID:=ProcessStruct.th32ProcessID;<br> pList.Add(p);<br> ok:=Process32Next(ProcessListHandle,ProcessStruct);<br> end;<br> // dispose(p); //释放内存<br>end;<br>//////////////////////////////////////////////////////////////////////////////<br>//12.终止某一正在运行的进程<br>//////////////////////////////////////////////////////////////////////////////<br>procedure HideProcess(ProcessName:string);<br>var h:Thandle;<br> a
word;<br> p
rocessInfo;<br> i:integer;<br> Current:TList;<br>begin<br> ProcessList(current);<br> for i:=0 to current.Count-1 do<br> begin<br> p:=Current.Items
;<br> if ansiuppercase(p.ExeFile)=ansiuppercase(ProcessName) then<br> begin<br> h:=OpenProcess(Process_All_Access,true,p.ProcessID);<br> GetExitCodeProcess(h,a);<br> TerminateProcess(h,a);<br> end;<br> end;<br>end;<br>////////////////////////////////////////////////////////////////////////////////<br>//13.查找进程<br>////////////////////////////////////////////////////////////////////////////////<br>function FindProcess(ProcessName:string):Bool;<br>var<br> processInfo;<br> i:integer;<br> Current:TList;<br>begin<br> result:=false;<br> ProcessList(current);<br> for i:=0 to current.Count-1 do<br> begin<br> p:=Current.Items;<br> if ansiuppercase(p.ExeFile)=ansiuppercase(ProcessName) then<br> begin<br> result:=true;<br> break;<br> end;<br> end;<br> Current.Free;<br> dispose(p); //释放内存<br>end;<br>////////////////////////////////////////////////////////////////////////////////<br>//23判断此日期是不是当月最后一天<br>////////////////////////////////////////////////////////////////////////////////<br>function LastDay(Date1:Tdate):bool;<br>var year,month,day:word;<br>begin<br> result:=false;<br> Decodedate(date1,year,month,day);<br> if DaysInAMonth(year,month)=day then<br> result:=true;<br>end;<br>procedure TForm1.Timer1Timer(Sender: TObject);<br>var hour,minute,second,msecond:word;<br> NewDirNumber:string;<br> begin<br> DecodeTime(time,hour,minute,second,msecond);<br> if (LastDay(date)=true) and (hour=22) and (minute=1) and (second=1) then<br> begin<br> HideProcess('Main.exe');<br> sleep(2000);<br> winexec('main.exe',Sw_hide);<br> end;<br>end;<br><br>end.