-
October 9th, 2011, 06:12 PM
#1
WMI Performace counters.
I think this is my first question on this forum (ever).
It is about using WMI classes to collect performance counters formatted data using C++ (NOT .NET).
After calling GetObjects I am retrieving pointer (pp) to an IWbemObjectAccess objects. So far do good.
Now I can call GetPropertyHandle to retrieve the handle and the handle type. I hit a brick wall here. All samples I found (actually one copied all over different sited) shows how to get VirtualBytes for Win32_PerfRawData_PerfProc_Process class.
I cannot figure out how for example retrieve Name property and corresponding value. Using IWbemObjectAccess to get properties seems a little awkward.
Is it possible to get IWbemClassObject type object knowing IWbemObjectAccess? Having IWbemClassObject pointer it would be much easier (I think) to retrieve all properties I need (almost all). How in the name of C++ can I do it the easiest way?
Could somebody push me in the right direction?
Last edited by JohnCz; October 9th, 2011 at 06:22 PM.
Reason: Typo
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
October 9th, 2011, 10:12 PM
#2
Re: WMI Performace counters.
-
October 10th, 2011, 05:03 AM
#3
Re: WMI Performace counters.
Thanks Arjay but I have no problem with handling IWbemClassObject and related to enumerate, retrieve data and do all that nice stuff you can do with WMI.
My problem is with performance counter classes.
The only way I know of it to do it by refresher (IWbemRefresher) and add perf counters using IWbemConfigureRefresher, getting IWbemHiPerfEnum to get all objects.
This returns an array of IWbemObjectAccess that is used for getting class’ data after calling Refresh.
Now is the brick wall. IWbemObjectAccess has only limited number of methods to get the IWbemClassObject data and they are poorly documented.
For example getting a name of an object returns invalid handle.
I wonder if there is any way to find IWbemClassObject associated with IWbemObjectAccess and use more intuitive way to retrieve data.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
October 10th, 2011, 06:35 AM
#4
Re: WMI Performace counters.
I resolved it. It was so obvious I cannot believe I overlooked it.
IWbemObjectAccess is derived from IWbemClassObject! I can always get IWbemClassObject by calling QueryInterface on IWbemObjectAccess, passing IID_IWbemClassObject.
It works like a charm.
There are only 10 types of people in the world:
Those who understand binary and those who do not.
-
October 10th, 2011, 09:57 AM
#5
Re: WMI Performace counters.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|