SetupFactory关闭指定进程
1、使用SetupFactory提供的函数
table Window.EnumerateProcesses ( boolean Toplevel = true )
2、Lua代码实现
1 function FindAndCloseProcessByName(strName) 2 local tblProcesses = Window.EnumerateProcesses(false); 3 local bProcessFound = false; 4 local nProcessHandle = nil; 5 if Table.Count(tblProcesses) > 0 then 6 local strProcessName; 7 local nHandle; 8 for nHandle,strProcessName in pairs(tblProcesses) do 9 if(String.Find(strProcessName,strName,1,false) ~= -1)then 10 nProcessHandle = nHandle; 11 bProcessFound = true; 12 end 13 end 14 end 15 if(bProcessFound and nProcessHandle)then 16 Window.Close(nProcessHandle,CLOSEWND_TERMINATE); 17 end 18 end
3、代码适用于SetupFactory9的版本