http://bbs.hanzify.org/simple/?t46901.html
你不用函数不就可以了吗,直接在你要执行操作的地方写代码:
CODE
strName = "msnmsgr.exe";
tblProcesses = Window.EnumerateProcesses(false);
bProcessFound = false;
nProcessHandle = nil;
if(tblProcesses)then
for nHandle, strProcessName in 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
tblProcesses = Window.EnumerateProcesses(false);
bProcessFound = false;
nProcessHandle = nil;
if(tblProcesses)then
for nHandle, strProcessName in 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