$PBExportHeader$f_proc_terminate.srf global type f_proc_terminate from function_object end type forward prototypes global function long f_proc_terminate (string arg_proc_name) end prototypes global function long f_proc_terminate (string arg_proc_name);// 输入进程名,还回结束进程数 s_Process lst_Process //进程结构 ulong ln_Snapshot, ln_handle long ll_TermCount = 0 ln_Snapshot = CreateToolhelp32Snapshot(2,0) //在堆上创建进程快照 If (ln_Snapshot < 1) THEN RETURN -1 //出错则返回 lst_Process.StructSize = 296 //Win32api的Process结构大小 IF Process32First(ln_Snapshot,lst_Process) = 0 THEN RETURN -1//取第一个进程失败则返回 do while true if lst_Process.FileName = arg_proc_name then ln_handle = OpenProcess(1,false,lst_Process.ProcessID)// 1:PROCESS_TERMINATE if TerminateProcess(ln_handle,0) then ll_TermCount++ end if end if IF Process32Next(ln_Snapshot,lst_Process) = 0 THEN EXIT //列举完毕 loop return ll_TermCount end function