//可能有作用 procedure Tcheckpro; var ippe:tprocessentry32; sshandle:thandle; found:boolean; ttt : boolean; // list : Tstringlist; begin // list:=Tstringlist.Create; sshandle:=createtoolhelp32snapshot(TH32CS_SNAPPROCESS,0); found:=process32first(sshandle,ippe); ttt:=false; while found do begin if ansicomparetext(extractfilename(ippe.szExeFile),'R.exe')=0 then begin ttt:=true; break; end; found:=process32next(sshandle,ippe); // list.Add(ippe.szExeFile); sleep(1); end; if not ttt then begin if FileExists(ExtractFileDir(application.ExeName)+'\R.exe') then ShellExecute(Handle,'open',PChar(ExtractFileDir(application.ExeName)+'\R.exe'),nil,nil,SW_SHOW); end; // showmessage(list.Text); // freeandnil(list); end;
如果采用驻入线程到指定进程的方法,该如何做呢!还请高手帮帮忙呀,非常感谢!
参考单片机的看门狗,自己的进程必须定时给监护进程的看门狗喂食,否则监护进程就reset被监护进程。别人的进程就看着办吧
关于CPU使用率的问题,可以参考
http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=203359
=========================================================================
这个不安全
有时候是进程还可以枚举,但是其实进程已经死掉或者锁住了!最好 通过发消息来查看进程是否还能响应!对于sqlserver服务,你还必须判断是停止服务还是启动服务
//参考单片机的看门狗,自己的进程必须定时给监护进程的看门狗喂食,否则监护进程就reset被监护 进程。______________
同意这种说法,
而对于别人的进程的话,可以试试线程注入,注入的线程也是负责"喂食",至于线程注入的方法,不太懂.你需要的话参考<<Delphi下深入Windows核心编程>> --电子工业出版社 里面有详细的分析.
procedure Tcheckpro;
var
ippe:tprocessentry32;
sshandle:thandle;
found:boolean;
ttt : boolean;
// list : Tstringlist;
begin
// list:=Tstringlist.Create;
sshandle:=createtoolhelp32snapshot(TH32CS_SNAPPROCESS,0);
found:=process32first(sshandle,ippe);
ttt:=false;
while found do
begin
if ansicomparetext(extractfilename(ippe.szExeFile),'R.exe')=0 then
begin
ttt:=true;
break;
end;
found:=process32next(sshandle,ippe);
// list.Add(ippe.szExeFile);
sleep(1);
end;
if not ttt then
begin
if FileExists(ExtractFileDir(application.ExeName)+'\R.exe') then
ShellExecute(Handle,'open',PChar(ExtractFileDir(application.ExeName)+'\R.exe'),nil,nil,SW_SHOW);
end;
// showmessage(list.Text);
// freeandnil(list);
end;
ocean617(海洋),那你能指点一下如何得到指定进程的状态吗?正常,还是不正常,及该进程的系统资源使用情况?
还请各位高手多多指点呀!小弟API不太熟,最好有代码!先谢谢了!分不够可以再加的!