Setup Factory 关闭正在运行的程序

--在全局函数中增加 适用用Setup Factory 9

function FindAndCloseProcessByName(strName)
  local tblProcesses = Window.EnumerateProcesses(false);
  local bProcessFound = false;
  local nProcessHandle = nil; 
if Table.Count(tblProcesses) > 0 then
 local strProcessName;
 local nHandle;
 for nHandle,strProcessName in pairs(tblProcesses) do
  if(String.Find(strProcessName,strName,1,false) ~= -1)then
  nProcessHandle = nHandle;
  bProcessFound = true;
  end
 end
end
if(bProcessFound and nProcessHandle)then
 Window.Close(nProcessHandle,CLOSEWND_TERMINATE); 
end
end

--调用

FindAndCloseProcessByName("DMS_Client.exe");
FindAndCloseProcessByName("DMSAutoUpdate.exe");

--或者直接调用

strName = "Lx_Update.exe";
tblProcesses = Window.EnumerateProcesses(false);
bProcessFound = false;
nProcessHandle = nil;
if(tblProcesses)then
for nHandle, strProcessName in pairs(tblProcesses) do
  if(String.Find(strProcessName,strName,1,false) ~= -1)then
   nProcessHandle = nHandle;
   bProcessFound = true;
  end
end
end

if(bProcessFound and nProcessHandle)then
Window.Close(nProcessHandle,CLOSEWND_TERMINATE);
end

上一篇:glibc与MSVC CRT(转载)


下一篇:表示即将废弃一个方法,或不赞成使用的一个方法或属性或其它,关键词 deprecated