Что содержится в переменной $exe?
Цитата mitiya:
ProcessClose($exe) в свою очередь всегда работает нормально , но он не убивает все дерево. »
|
Вот функция для убийства дерева процесса:
Код:

_ProcessCloseTree("Test.exe")
Func _ProcessCloseTree($iPID)
If IsString($iPID) Then
$iPID = ProcessExists($iPID)
EndIf
If Not $iPID Then
Return SetError(-1, 0, $iPID)
EndIf
Local Const $TH32CS_SNAPPROCESS = 0x00000002
Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
If Not IsArray($a_tool_help) Or $a_tool_help[0] = -1 Then
Return SetError(1, 0, $iPID)
EndIf
Local $tagPROCESSENTRY32 = _
DllStructCreate( _
"dword dwsize;" & _
"dword cntUsage;" & _
"dword th32ProcessID;" & _
"uint th32DefaultHeapID;" & _
"dword th32ModuleID;" & _
"dword cntThreads;" & _
"dword th32ParentProcessID;" & _
"long pcPriClassBase;" & _
"dword dwFlags;" & _
"char szExeFile[260]")
DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))
Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)
Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
If Not IsArray($a_pfirst) Then
Return SetError(2, 0, $iPID)
EndIf
Local $a_pnext, $i_child_pid, $i_parent_pid
$i_child_pid = DllStructGetData($tagPROCESSENTRY32, "th32ProcessID")
If $i_child_pid <> $iPID Then
$i_parent_pid = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
If $i_parent_pid = $iPID Then
_ProcessCloseTree($i_child_pid)
If @error <> 0 Then
ProcessClose($i_child_pid)
EndIf
EndIf
EndIf
While 1
$a_pnext = DllCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
If IsArray($a_pnext) And $a_pnext[0] = 0 Then
ExitLoop
EndIf
$i_child_pid = DllStructGetData($tagPROCESSENTRY32, "th32ProcessID")
If $i_child_pid <> $iPID Then
$i_parent_pid = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
If $i_parent_pid = $iPID Then
_ProcessCloseTree($i_child_pid)
If @error <> 0 Then
ProcessClose($i_child_pid)
EndIf
EndIf
EndIf
WEnd
DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
Return 1
EndFunc