Sign in to follow this  
Followers 0
gooker

How to get process mem byPID

5 posts in this topic

:)

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

Share this post


Link to post
Share on other sites



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
EndFunc

Win32_Process: http://msdn.microsoft.com/en-us/library/aa394372(VS.85).aspx

Share this post


Link to post
Share on other sites

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


Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

:)

I want by Pid,and i search and find the answer;

whatever.thank you 谢谢


Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0