HORRIBLE,
Цитата HORRIBLE:
возвращает массив пустой »
|
Можно ещё так:
Код:

#include <Array.au3>
$aProcessInfo = _ProcListByUserName(@UserName)
_ArrayDisplay($aProcessInfo)
Func _ProcListByUserName($sUserName = @UserName)
Local $oColItems, $objWMIService, $objItem, $cI_Compname = @ComputerName
Local $aProcessList[1]
$objWMIService = ObjGet("winmgmts:\\" & $cI_Compname & "\root\CIMV2")
$oColItems = $objWMIService.ExecQuery("SELECT * FROM Win32_Process", "WQL")
If Not IsObj($oColItems) Then Return SetError(1, 2, 0)
For $objItem In $oColItems
If _GetExtProperty($objItem.ExecutablePath, 8) <> $sUserName Then ContinueLoop
$aProcessList[0] += 1
ReDim $aProcessList[$aProcessList[0] + 1]
$aProcessList[$aProcessList[0]] = $objItem.Caption
Next
Return $aProcessList
EndFunc
Func _GetExtProperty($sPath, $iProp)
Local $iExist, $sFile, $sDir, $oShellApp, $oDir, $oFile, $aProperty, $sProperty
$iExist = FileExists($sPath)
If $iExist = 0 Then Return SetError(1, 0, 0)
$sFile = StringTrimLeft($sPath, StringInStr($sPath, "\", 0, -1))
$sDir = StringTrimRight($sPath, (StringLen($sPath) - StringInStr($sPath, "\", 0, -1)))
$oShellApp = ObjCreate("shell.application")
$oDir = $oShellApp.NameSpace($sDir)
$oFile = $oDir.Parsename($sFile)
If $iProp = -1 Then
Local $aProperty[35]
For $i = 0 To 34
$aProperty[$i] = $oDir.GetDetailsOf($oFile, $i)
Next
Return $aProperty
Else
$sProperty = $oDir.GetDetailsOf($oFile, $iProp)
If $sProperty = "" Then Return 0
Return $sProperty
EndIf
EndFunc
Хотя тоже не надёжно, но я других методов не знаю
