$iPid = ProcessExists("et.exe")
$path = _GetModuleFileNameEx($iPid)
;~ MsgBox(0,0,$path)
Local $MonitorDir = StringRegExpReplace($path, '(.+\\)[^\\]+', '\1')
;~ MsgBox(0, 0, $MonitorDir)
While 1
$array = ProcessList()
For $i = 1 To $array[0][0]
;~ MsgBox(0,0,_GetModuleFileNameEx($array[$i][1]))
If StringInStr(_GetModuleFileNameEx($array[$i][1]), $MonitorDir) Then
If ProcessExists($array[$i][1]) <> $iPid Then ;判断下要结束的进程和被排除的进程PID是否相同
MsgBox(0, 0, $array[$i][1])
ProcessClose($array[$i][1])
EndIf
EndIf
Next
Sleep(250)
WEnd
Func _GetModuleFileNameEx($_Pid)
$_Hwnd = DllCall("Kernel32.dll", "hwnd", "OpenProcess", "dword", 0x0400 + 0x0010, "int", 0, "dword", $_Pid)
$_Return = DllCall("Psapi.dll", "long", "GetModuleFileNameEx", "hwnd", $_Hwnd[0], "long", 0, "str", 0, "long", 255)
DllCall("Kernel32.dll", "int", "CloseHandle", "hwnd", $_Hwnd[0])
If StringInStr($_Return[3], "") Then Return $_Return[3]
Return ""
EndFunc ;==>_GetModuleFileNameEx
|