使用WMI时,Win32_Process class Process.PrivateMemorySize64属性中的等效成员?我看到了各种内存字段,但我不确定它们中哪一个是正确的。
这个问题是关于.NET中特定WMI类的用法,无论语言如何,但我理解我所做的问题太短,所以我只想分享用VB.NET编写的这个代码示例来了解我的内容想通过WMI实现:
Dim scope As New ManagementScope("root\CIMV2")
Dim query As New SelectQuery(String.Format("SELECT * FROM Win32_Process Where ProcessId = '{0}'", pId))
Dim options As New EnumerationOptions With {.ReturnImmediately = True, .DirectRead = True}
Using wmi As New ManagementObjectSearcher(scope, query, options)
Using obj As ManagementObject = wmi.Get().Cast(Of ManagementObject).Single()
Dim memSize As ULong = CULng(obj.Properties("PrivateMemorySize?").Value)
End Using
End Using