Obtient les informations de limite et d'�tat de la t�che d'un objet Job
#include <WinAPIProc.au3>
_WinAPI_QueryInformationJobObject ( $hJob, $iJobObjectInfoClass, ByRef $tJobObjectInfo )
$hJob | Handle de la t�che dont vous voulez les informations. Le handle doit avoir le droit d'acc�s $JOB_OBJECT_QUERY. Si cette valeur est 0 et le processus appelant est associ� � une t�che, la t�che associ�e au processus d'appel est utilis�e. |
$iJobObjectInfoClass | La classe d'information pour les limites � obtenir. Ce param�tre sp�cifie le type de la structure $tJobObjectInfo, les valeurs valables sont: 1 - $tagJOBOBJECT_BASIC_ACCOUNTING_INFORMATION 2 - $tagJOBOBJECT_BASIC_LIMIT_INFORMATION 3 - $tagJOBOBJECT_BASIC_PROCESS_ID_LIST 4 - $tagJOBOBJECT_BASIC_UI_RESTRICTIONS 5 - $tagJOBOBJECT_SECURITY_LIMIT_INFORMATION 8 - $tagJOBOBJECT_BASIC_AND_IO_ACCOUNTING_INFORMATION 9 - $tagJOBOBJECT_EXTENDED_LIMIT_INFORMATION 11 - $tagJOBOBJECT_GROUP_INFORMATION |
$tJobObjectInfo | La structure $tagJOBOBJECT_* (voir ci-dessus) qui r�cup�re les informations de limite et d'�tat de la t�che. Cette structure doit �tre cr��e avant l'appel de la fonction. |
Succ�s: | Retourne la longueur des donn�es (en octets) �crites dans la structure point�e par le param�tre $tJobObjectInfo. |
�chec: | Retourne 0, appelez _WinAPI_GetLastError() pour obtenir des informations suppl�mentaires sur l'erreur. |
Consultez QueryInformationJobObject dans la librairie MSDN.
#include <APIProcConstants.au3> #include <WinAPIConv.au3> #include <WinAPIHObj.au3> #include <WinAPIProc.au3> Local Const $sTemp = @TempDir & '\Test.au3' ; Cr�e un fichier temporaire .au3 Local $hFile = FileOpen($sTemp, 2) For $i = 1 To 3 FileWriteLine($hFile, 'Run(@SystemDir & "\calc.exe")' & @CRLF & 'Sleep(100)') Next FileClose($hFile) ; Ex�cute 3 fois "calc.exe" et attend jusqu'� ce que vous ayez ferm� tous les 3 processus _RunWaitEx(@AutoItExe & '/AutoIt3ExecuteScript "' & $sTemp & '"') ; Supprime le fichier temporaire .au3 FileDelete($sTemp) Func _RunWaitEx($sCmd) ; Id�e originale de amel27 Local $tProcess = DllStructCreate($tagPROCESS_INFORMATION) Local $tStartup = DllStructCreate($tagSTARTUPINFO) Local $tInfo = DllStructCreate($tagJOBOBJECT_BASIC_ACCOUNTING_INFORMATION) Local $hJob = _WinAPI_CreateJobObject() If Not $hJob Then Return SetError(1, 0, 0) DllStructSetData($tStartup, 'Size', DllStructGetSize($tStartup)) If Not _WinAPI_CreateProcess('', $sCmd, 0, 0, 0, BitOR($CREATE_BREAKAWAY_FROM_JOB, $CREATE_SUSPENDED), 0, 0, DllStructGetPtr($tStartup), DllStructGetPtr($tProcess)) Then Return SetError(1, _WinAPI_CloseHandle($hJob), 0) EndIf Local $hProcess = DllStructGetData($tProcess, 'hProcess') Local $hThread = DllStructGetData($tProcess, 'hThread') _WinAPI_AssignProcessToJobObject($hJob, $hProcess) _WinAPI_ResumeThread($hThread) _WinAPI_CloseHandle($hThread) Do If Not _WinAPI_QueryInformationJobObject($hJob, 1, $tInfo) Then ExitLoop EndIf Sleep(100) Until Not DllStructGetData($tInfo, 'ActiveProcesses') _WinAPI_CloseHandle($hProcess) _WinAPI_CloseHandle($hJob) Return 1 EndFunc ;==>_RunWaitEx Func _WinAPI_ResumeThread($hThread) Local $aRet = DllCall('kernel32.dll', 'dword', 'ResumeThread', 'ptr', $hThread) If @error Or (_WinAPI_DWordToInt($aRet[0]) = -1) Then Return SetError(1, 0, -1) Return $aRet[0] EndFunc ;==>_WinAPI_ResumeThread