WMI Performace counters.
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: WMI Performace counters.

  1. #1
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    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.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    10,956

    Re: WMI Performace counters.

    See if the WMI class I wrote in my reply here helps you.

    http://www.codeguru.com/forum/showthread.php?t=482627

    Then I updated some functionality here:

    http://www.codeguru.com/forum/showpo...57&postcount=8

  3. #3
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    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.

  4. #4
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    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.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    10,956

    Re: WMI Performace counters.

    Great.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center