gooker Posted May 11, 2008 Posted May 11, 2008 below is get process mem by name(WMI),and i want to know how to get it by PID?? Func _ProcessMem($ProcessName) Local $colItems = "" Local $strComputer = "localhost" Local $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems =$objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & $ProcessName& "'") For $objItem In $colItems Local $mem=$objItem.WorkingSetSize /1024 Return Int($mem) Next EndFunc
nfwu Posted May 11, 2008 Posted May 11, 2008 Func _ProcessMem_ByPID($ProcessID) Local $colItems = "" Local $strComputer = "localhost" Local $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems =$objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE ProcessId = '" & $ProcessID& "'") For $objItem In $colItems Local $mem=$objItem.WorkingSetSize /1024 Return Int($mem) Next EndFuncWin32_Process: http://msdn.microsoft.com/en-us/library/aa394372(VS.85).aspx TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
gooker Posted May 11, 2008 Author Posted May 11, 2008 ths iget it $strComputer = "." $objWMIService = ObjGet("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" _ & $strComputer & "\root\cimv2") $colProcesses = $objWMIService.ExecQuery _ ("Select * from Win32_Process") For $objProcess in $colProcesses ConsoleWrite( "Process ID: " & $objProcess.ProcessID & @CRLF ) ConsoleWrite( "Working $Size: " _ & $objProcess.WorkingSetSize & @CRLF ) Next
nfwu Posted May 11, 2008 Posted May 11, 2008 Oh, so you wanted PID by name? Func _ProcessPID($ProcessName) Local $colItems = "" Local $strComputer = "localhost" Local $Output="" $Output = $Output & "Computer: " & $strComputer & @CRLF Local $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2") Local $colItems =$objWMIService.ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" & $ProcessName& "'") For $objItem In $colItems Return Int($objItem.ProcessID) Next EndFunc TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode()
gooker Posted May 11, 2008 Author Posted May 11, 2008 I want by Pid,and i search and find the answer; whatever.thank you 谢谢
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now