Имя пользователя:
Пароль:  
Помощь | Регистрация | Забыли пароль?  

Показать сообщение отдельно

Аватара для Creat0R

Must AutoIt


Сообщения: 3054
Благодарности: 1009

Профиль | Сайт | Отправить PM | Цитировать


Можно искать в списке процессов по исполняемому пути к процессу:

Код: Выделить весь код
$aRun_Processes = StringSplit(@SystemDir & "\Notepad.exe" & "|" & @WindowsDir & "\Regedit.exe", "|")

HotKeySet("{ESC}", "_Quit")

While 1
    Sleep(1000)
    $aProcList = _ProcessListEx()

    For $i = 1 To $aRun_Processes[0]
        $bFound = False

        For $j = 1 To $aProcList[0][0]
            If $aProcList[$j][2] = $aRun_Processes[$i] Then
                $bFound = True
            EndIf
        Next

        If Not $bFound Then
            Run($aRun_Processes[$i])
        EndIf
    Next
WEnd

Func _Quit()
    Exit
EndFunc

Func _ProcessListEx($sResourceName="", $sInResString="", $iWholeWord=1)
    Local $aProcList = ProcessList()
    Local $hKernel32_Dll = DllOpen('Kernel32.dll'), $hPsapi_Dll = DllOpen('Psapi.dll')
    Local $aOpenProc, $aProcPath, $sFileVersion, $aRet_List[1][1]

    If $hKernel32_Dll = -1 Then Return SetError(1, 0, '')

    If $hPsapi_Dll = -1 Then $hPsapi_Dll = DllOpen(@SystemDir & '\Psapi.dll')
    If $hPsapi_Dll = -1 Then $hPsapi_Dll = DllOpen(@WindowsDir & '\Psapi.dll')
    If $hPsapi_Dll = -1 Then Return SetError(2, 0, '')

    Local $vStruct      = DllStructCreate('int[1024]')
    Local $pStructPtr   = DllStructGetPtr($vStruct)
    Local $iStructSize  = DllStructGetSize($vStruct)

    For $i = 1 To UBound($aProcList)-1
        $aOpenProc = DllCall($hKernel32_Dll, 'hwnd', 'OpenProcess', _
            'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $aProcList[$i][1])

        If Not IsArray($aOpenProc) Or Not $aOpenProc[0] Then ContinueLoop

        DllCall($hPsapi_Dll, 'int', 'EnumProcessModules', _
            'hwnd', $aOpenProc[0], _
            'ptr', $pStructPtr, _
            'int', $iStructSize, _
            'int*', 0)

        $aProcPath = DllCall($hPsapi_Dll, 'int', 'GetModuleFileNameEx', _
            'hwnd', $aOpenProc[0], _
            'int', DllStructGetData($vStruct, 1), _
            'str', '', _
            'int', 2048)

        DllCall($hKernel32_Dll, 'int', 'CloseHandle', 'int', $aOpenProc[0])

        If Not IsArray($aProcPath) Or StringLen($aProcPath[3]) = 0 Then ContinueLoop

        $sFileVersion = FileGetVersion($aProcPath[3], $sResourceName)

        If $sResourceName = "" Or $sFileVersion = $sInResString Or _
            ($iWholeWord = 0 And StringInStr($sFileVersion, $sInResString)) Then

            $aRet_List[0][0] += 1
            ReDim $aRet_List[$aRet_List[0][0]+1][3]
            $aRet_List[$aRet_List[0][0]][0] = $aProcList[$i][0]     ;Process Name
            $aRet_List[$aRet_List[0][0]][1] = $aProcList[$i][1]     ;PID (Process ID)
            $aRet_List[$aRet_List[0][0]][2] = $aProcPath[3]         ;Process File Path
        EndIf
    Next

    DllClose($hKernel32_Dll)
    DllClose($hPsapi_Dll)

    If $aRet_List[0][0] < 1 Then Return SetError(3, 0, '')
    Return $aRet_List
EndFunc

-------
“Сделай так просто, как возможно, но не проще этого.”... “Ты никогда не решишь проблему, если будешь думать так же, как те, кто её создал.”

Альберт Эйнштейн

P.S «Не оказываю техподдержку через ПМ/ICQ, и по email - для этого есть форум. ©»

http://creator-lab.ucoz.ru/Images/Icons/autoit_icon.png Русское сообщество AutoIt | http://creator-lab.ucoz.ru/Images/Ic...eator_icon.png CreatoR's Lab | http://creator-lab.ucoz.ru/Images/Icons/oac_icon.png Opera AC Community


Отправлено: 13:03, 14-07-2010 | #2