我要停止正在运行的进程,应该怎么做呢?
用kill杀死进程吗?
哪位大侠能具体给点代码看看

解决方案 »

  1.   

    假设要终止的程序的文件名为:project2.exe,那么例程如下:varlppe:tprocessentry32;sshandle:thandle;hh:hwnd;found:boolean;beginsshandle:=createtoolhelp32snapshot(TH32CS_SNAPALL,0);found:=process32first(sshandle,lppe);while found dobegin//进行你的处理其中lppe.szExefile就是程序名。if uppercase(extractfilename(lppe.szExeFile))='PROJECT2.EXE' thenbeginhh:=OpenProcess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID);TerminateProcess(hh,0);end;found:=process32next(sshandle,lppe);end;end;
      

  2.   

    TerminateProcess(yourProcess.handle, 0)
      

  3.   

    BOOL TerminateProcess(
      HANDLE hProcess,
      UINT uExitCode
    );