比如我在启动里加入calc.exe,每次开机都运行calc.exe(也就是计算器),我想实现在每个月的月初也就是1号进行检测,calc.exe是否在运行,如果在运行就关闭它,请问这个程序应该如何写?操作系统是win2000个人版!

解决方案 »

  1.   

    if Dayof(now) = 1 then begin
      find the calc.exe and return the handle,
      if found, then send the wm_close messaeg to itend;
      

  2.   

    var
     FSnapshotHandle:THandle;
     FProcessEntry32:TProcessEntry32;
     Ret : BOOL;
     ProcessID : integer;
     s:string;
    begin
     FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
     FProcessEntry32.dwSize:=Sizeof(FProcessEntry32);
     Ret:=Process32First(FSnapshotHandle,FProcessEntry32);
     Memo1.clear;
     while Ret do
     begin
       Memo1.lines.add(FProcessEntry32.szExeFile);
       s:=ExtractFileName(FProcessEntry32.szExeFile);
       if s='calc.exe 'then
       begin
         ProcessID:=FProcessEntry32.th32ProcessID;
         TerminateProcess(OpenProcess(PROCESS_TERMINATE,false,ProcessID),1);
         s:='';
       end;
       Ret:=Process32Next(FSnapshotHandle,FProcessEntry32);
     end;
    end;