Global $Window = "KILL ME, I'M IN HELL!!!"
WinSetState($Window, '', @SW_HIDE) ;Прячем окно
_ProcessSuspend(WinGetProcess($Window)) ;"Заморозка" процесса
Func _ProcessSuspend($vProcess, $iReserved = 0)
Local $iPid, $vTmp, $hThreadSnap, $ThreadEntry32, $iThreadID, $hThread, $iThreadCnt, $iThreadCntSuccess, $sFunction
Local $TH32CS_SNAPTHREAD = 0x00000004
Local $INVALID_HANDLE_VALUE = 0xFFFFFFFF
Local $THREAD_SUSPEND_RESUME = 0x0002
Local $THREADENTRY32_StructDef = "int;" _; 1 -> dwSize
& "int;" _; 2 -> cntUsage
& "int;" _; 3 -> th32ThreadID
& "int;" _; 4 -> th32OwnerProcessID
& "int;" _; 5 -> tpBasePri
& "int;" _; 6 -> tpDeltaPri
& "int" ; 7 -> dwFlags
$iPid = ProcessExists($vProcess)
If Not $iPid Then Return SetError(1, 0, False) ; Process not found.
$vTmp = DllCall("kernel32.dll", "ptr", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPTHREAD, "int", 0)
If @error Then Return SetError(2, 0, False) ; CreateToolhelp32Snapshot Failed
If $vTmp[0] = $INVALID_HANDLE_VALUE Then Return SetError(2, 0, False) ; CreateToolhelp32Snapshot Failed
$hThreadSnap = $vTmp[0]
$ThreadEntry32 = DllStructCreate($THREADENTRY32_StructDef)
DllStructSetData($ThreadEntry32, 1, DllStructGetSize($ThreadEntry32))
$vTmp = DllCall("kernel32.dll", "int", "Thread32First", "ptr", $hThreadSnap, "long", DllStructGetPtr($ThreadEntry32))
If @error Then Return SetError(3, 0, False) ; Thread32First Failed
If Not $vTmp[0] Then
DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $hThreadSnap)
Return SetError(3, 0, False) ; Thread32First Failed
EndIf
While 1
If DllStructGetData($ThreadEntry32, 4) = $iPid Then
$iThreadID = DllStructGetData($ThreadEntry32, 3)
$vTmp = DllCall("kernel32.dll", "ptr", "OpenThread", "int", $THREAD_SUSPEND_RESUME, "int", False, "int", $iThreadID)
If Not @error Then
$hThread = $vTmp[0]
If $hThread Then
If $iReserved Then
$sFunction = "ResumeThread"
Else
$sFunction = "SuspendThread"
EndIf
$vTmp = DllCall("kernel32.dll", "int", $sFunction, "ptr", $hThread)
If $vTmp[0] <> -1 Then $iThreadCntSuccess += 1
DllCall("kernel32.dll", "int", "CloseHandle", "ptr", $hThread)
EndIf
EndIf
$iThreadCnt += 1
EndIf
$vTmp = DllCall("kernel32", "int", "Thread32Next", "ptr", $hThreadSnap, "long", DllStructGetPtr($ThreadEntry32))
If @error Then Return SetError(4, 0, False) ; Thread32Next Failed
If Not $vTmp[0] Then ExitLoop
WEnd
DllCall("kernel32.dll", "int", "CloseToolhelp32Snapshot", "ptr", $hThreadSnap) ; CloseHandle
If Not $iThreadCntSuccess Or $iThreadCnt > $iThreadCntSuccess Then Return SetError(5, $iThreadCnt, $iThreadCntSuccess)
Return SetError(0, $iThreadCnt, $iThreadCntSuccess)
EndFunc