解决了
本帖最后由 繁星 于 2015-4-22 12:17 编辑解决了{:face (356):} 找pid干什么 回复 2# netegg
通过找到PID来结束进程啊,因为ProcessClose结束指定进程的时候,如遇多个进程的名称相同, 则 PID 最高的进程将被结束 - 并不是以最近启动的进程为准.所以我才找PID想要准备的结束进程 processlist
_arraysort
processclose 这个用不着api 回复 5# netegg
如果是PING命令 ,会有两个进程,一个cmd,一个Ping ,ProcessList就不能返回当前运行进程的名称和 PID 值的数组. 回复 6# 繁星
你不是有进程名吗,管这些干吗?,进程名出来,pid也出来了 你都有地址了,直接结束文件名不就OK了~ 回复 6# 繁星
明显是只会"抄写"的新手. 这么小的数组,直接遍历搜出来就是了.Local $sSch = 'c:\windows\explorer.exe'
Local $sPIDS = ''
Local $sPath
For $i=1 to ubound($list,1)-1
$sPath = _WinAPI_GetCommandLineFromPID($list[$i])
If$sPath = $sSch Then $sPIDS &= @CRLF & $sPath
Next
MsgBox(0, $sSch, 'PID:' & $sPIDS) 借3000大侠的码,我给你补个完整的吧~~#include <WinAPI.au3>
#include <array.au3>
Global Const $PROCESS_VM_READ=0x10
Global Const $PROCESS_QUERY_INFORMATION = 0x400
_GetPrivilege_SEDEBUG()
$list=ProcessList()
Redim $list
Local $sSch = InputBox("请输入完整的路径", @CRLF & '例如:c:\windows\explorer.exe','c:\windows\explorer.exe')
Local $sPIDS = ''
Local $sPath
For $i=1 to ubound($list,1)-1
$sPath = _WinAPI_GetCommandLineFromPID($list[$i])
If$sPath = $sSch Then $sPIDS &= $list[$i]
Next
MsgBox(0, $sSch, $sSch & @CRLF & 'PID:' & $sPIDS)
Func _WinAPI_GetCommandLineFromPID($PID)
$ret1=DllCall("kernel32.dll", 'int', 'OpenProcess', 'int', $PROCESS_VM_READ+$PROCESS_QUERY_INFORMATION, 'int', False, 'int', $PID)
$tag_PROCESS_BASIC_INFORMATION = "int ExitStatus;" & _
"ptr PebBaseAddress;" & _
"ptr AffinityMask;" & _
"ptr BasePriority;" & _
"ulong UniqueProcessId;" & _
"ulong InheritedFromUniqueProcessId;"
$PBI=DllStructCreate($tag_PROCESS_BASIC_INFORMATION)
DllCall("ntdll.dll", "int", "ZwQueryInformationProcess", "hwnd", $ret1, "int", 0, "ptr", DllStructGetPtr($PBI), "int", _
DllStructGetSize($PBI), "int",0)
$dw=DllStructCreate("ptr")
DllCall("kernel32.dll", "int", "ReadProcessMemory", "hwnd", $ret1, _
"ptr", DllStructGetData($PBI,2)+0x10, _
"ptr", DllStructGetPtr($dw), "int", 4, "ptr", 0)
$unicode_string = DllStructCreate("ushort Length;ushort MaxLength;ptr String")
DllCall("kernel32.dll", "int", "ReadProcessMemory", "hwnd", $ret1, _
"ptr", DllStructGetData($dw, 1)+0x40, _
"ptr", DllStructGetPtr($unicode_string), "int", DllStructGetSize($unicode_string), "ptr", 0)
$ret=DllCall("kernel32.dll", "int", "ReadProcessMemory", "hwnd", $ret1, _
"ptr", DllStructGetData($unicode_string, "String"), _
"wstr", 0, "int", DllStructGetData($unicode_string, "Length") + 2, "int*", 0)
DllCall("kernel32.dll", 'int', 'CloseHandle', "hwnd", $ret1)
If $ret Then Return $ret
Return ""
EndFunc
Func _GetPrivilege_SEDEBUG()
Local $tagLUIDANDATTRIB = "int64 Luid;dword Attributes"
Local $count = 1
Local $tagTOKENPRIVILEGES = "dword PrivilegeCount;byte LUIDandATTRIB[" & $count * 12 & "]"
Local $TOKEN_ADJUST_PRIVILEGES = 0x20
Local $call = DllCall("advapi32.dll", "int", "OpenProcessToken", "ptr", _WinAPI_GetCurrentProcess(), "dword", $TOKEN_ADJUST_PRIVILEGES, "ptr*", "")
Local $hToken = $call
$call = DllCall("advapi32.dll", "int", "LookupPrivilegeValue", "str", Chr(0), "str", "SeDebugPrivilege", "int64*", "")
Local $iLuid = $call
Local $TP = DllStructCreate($tagTOKENPRIVILEGES)
Local $LUID = DllStructCreate($tagLUIDANDATTRIB, DllStructGetPtr($TP, "LUIDandATTRIB"))
DllStructSetData($TP, "PrivilegeCount", $count)
DllStructSetData($LUID, "Luid", $iLuid)
DllStructSetData($LUID, "Attributes", $SE_PRIVILEGE_ENABLED)
$call = DllCall("advapi32.dll", "int", "AdjustTokenPrivileges", "ptr", $hToken, "int", 0, "ptr", DllStructGetPtr($TP), "dword", 0, "ptr", Chr(0), "ptr", Chr(0))
Return ($call <> 0)
EndFunc $list = progresslist($progressname)
_arrausort($list,1)
progressclose($list)
页:
[1]