D
dgk
For the whole machine, not a specific process. I looked at an earlier
thread by Cor and Ken Tucker, but I don't find anything in the
management that looks like... Oh. Here is a really good site. Really,
I don't know the guy but just found it via Google. I guess I don't
need to post this anymore but just in case someone else is looking for
the info, here it is. It's in C# but nobody is perfect.
http://skilldrive.com/book/DOTNETinSamples.htm#_Toc112335378
Set a reference to System.Management and adapting the earlier thread's
code:
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject
moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")
moReturn = moSearch.Get
For Each mo In moReturn
Dim strout As String = String.Format("{0} - {1}", mo("Name"),
mo("LoadPercentage"))
Debug.WriteLine(strout)
Next
LoadPercentage is the key for what I was looking for. Two comments
about the code. First, why would there be more than one mo returned? I
guess multi-processor systems. I'll have to try it on my dual-core at
home.
Second, the "Select * from Win32_Processor" parameter. Kind of cute,
looks like a foreshadowing of DLINQ. Using SQL syntax for non-database
objects I think. Nice.
I started out by trying MY, as in My.Computer.Info but no CPU stuff is
there. Too bad, I'm getting spoiled by My.
thread by Cor and Ken Tucker, but I don't find anything in the
management that looks like... Oh. Here is a really good site. Really,
I don't know the guy but just found it via Google. I guess I don't
need to post this anymore but just in case someone else is looking for
the info, here it is. It's in C# but nobody is perfect.
http://skilldrive.com/book/DOTNETinSamples.htm#_Toc112335378
Set a reference to System.Management and adapting the earlier thread's
code:
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject
moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Processor")
moReturn = moSearch.Get
For Each mo In moReturn
Dim strout As String = String.Format("{0} - {1}", mo("Name"),
mo("LoadPercentage"))
Debug.WriteLine(strout)
Next
LoadPercentage is the key for what I was looking for. Two comments
about the code. First, why would there be more than one mo returned? I
guess multi-processor systems. I'll have to try it on my dual-core at
home.
Second, the "Select * from Win32_Processor" parameter. Kind of cute,
looks like a foreshadowing of DLINQ. Using SQL syntax for non-database
objects I think. Nice.
I started out by trying MY, as in My.Computer.Info but no CPU stuff is
there. Too bad, I'm getting spoiled by My.