ViSiToR

Silver Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору Nikkorot 12:48 30-11-2008 [?] Цитата: Хотелось бы сделать проверку наличия определенного запущенного процесса по имени, и пути, откуда он запущен | Код: $Path = _ProcessGetPath("AutoIt3.exe") ConsoleWrite($Path) ;=============================================================================== ; ; Function Name: _ProcessGetPath() ; Description: Get the executable path of certain process. ; ; Parameter(s): $vProcess - PID or name of a process. ; ; Requirement(s): AutoIt v3.2.8.1 or higher. ; Kernel32.dll (included with Windows) ; Psapi.dll (included with most Windows versions) ; ; Return Value(s): On Success - Returns full path to the executed process. ; On Failure - Returns -1 and sets @Error to: ; 1 - Given process not exists. ; 2 - Error to call Kernel32.dll. ; 3 - Error to open Psapi.dll. ; 4 - Unable to locate path of executed process, ; (or can be other error related to DllCall). ; ; Author(s): G.Sandler (a.k.a CreatoR) - CreatoR's Lab (http://creator-lab.ucoz.ru) ; ;=============================================================================== Func _ProcessGetPath($vProcess) Local $iPID = ProcessExists($vProcess) If Not $iPID Then Return SetError(1, 0, -1) Local $aProc = DllCall('kernel32.dll', 'hwnd', 'OpenProcess', 'int', BitOR(0x0400, 0x0010), 'int', 0, 'int', $iPID) If Not IsArray($aProc) Or Not $aProc[0] Then Return SetError(2, 0, -1) Local $vStruct = DllStructCreate('int[1024]') Local $hPsapi_Dll = DllOpen('Psapi.dll') 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(3, 0, '') DllCall($hPsapi_Dll, 'int', 'EnumProcessModules', _ 'hwnd', $aProc[0], _ 'ptr', DllStructGetPtr($vStruct), _ 'int', DllStructGetSize($vStruct), _ 'int_ptr', 0) Local $aRet = DllCall($hPsapi_Dll, 'int', 'GetModuleFileNameEx', _ 'hwnd', $aProc[0], _ 'int', DllStructGetData($vStruct, 1), _ 'str', '', _ 'int', 2048) DllClose($hPsapi_Dll) If Not IsArray($aRet) Or StringLen($aRet[3]) = 0 Then Return SetError(4, 0, '') Return $aRet[3] EndFunc | Ну или пройтись по массиву возвращённому от _ProcessListEx.
---------- ViSiToR a.k.a CreatoR CreatoR это не ник, CreatoR это стиль жизни! |
|