P
Physeth
My application is attemping to access some CPU info on a
local machine, but when I run it, I get an error message
of "Object reference not set to an instance of an object."
Most of this code works-I can use other categories and
query general info, so can anyone give me a hint?
Imports System
Imports System.Management
Module Module1
Sub Main()
Dim options As New ConnectionOptions
Dim IPAddress As New Integer
Dim TheMachine As String = "10.33.32.125"
Dim MyScope As New ManagementScope("\\" &
TheMachine & "\root\cimv2")
Dim strClassNetConf1 As String
= "Win32_PerfFormattedData_PerfOS_Processor"
Dim TheFilter As New SelectQuery("SELECT * FROM "
& strClassNetConf1)
Dim MySearcher As New ManagementObjectSearcher
(MyScope, TheFilter)
Dim mObject As ManagementObject
MyScope.Connect()
For Each mObject In MySearcher.Get()
Console.WriteLine(mObject.GetPropertyValue
("Caption").ToString)
Next mObject
End Sub
End Module
local machine, but when I run it, I get an error message
of "Object reference not set to an instance of an object."
Most of this code works-I can use other categories and
query general info, so can anyone give me a hint?
Imports System
Imports System.Management
Module Module1
Sub Main()
Dim options As New ConnectionOptions
Dim IPAddress As New Integer
Dim TheMachine As String = "10.33.32.125"
Dim MyScope As New ManagementScope("\\" &
TheMachine & "\root\cimv2")
Dim strClassNetConf1 As String
= "Win32_PerfFormattedData_PerfOS_Processor"
Dim TheFilter As New SelectQuery("SELECT * FROM "
& strClassNetConf1)
Dim MySearcher As New ManagementObjectSearcher
(MyScope, TheFilter)
Dim mObject As ManagementObject
MyScope.Connect()
For Each mObject In MySearcher.Get()
Console.WriteLine(mObject.GetPropertyValue
("Caption").ToString)
Next mObject
End Sub
End Module