Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 675175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:47:21+00:00 2026-05-14T00:47:21+00:00

I have an app that collects Perfmon counter values through the API exposed in

  • 0

I have an app that collects Perfmon counter values through the API exposed in winreg.h – in order to collect Perfmon counter values I must make a call to RegQueryValueExW passing in the id of the Perfmon counter I’m interested in, and in order to obtain that ID I need to query the registry for the list of Perfmon counter names and go through looking for the one I’m interested in

C++ isn’t my language of choice, so the following is a shaky example, probably with lots of syntax errors but you get the idea:

DWORD IdProcessIndex = 0;
WCHAR* RawStrings = new WCHAR[ len ];
WCHAR* pCurrent;
DWORD nLenInChars;

// Get the name id of the "ID Process" counter
RegQueryValueExW(HKEY_PERFORMANCE_DATA, COUNTER009, 0, 0, (PBYTE)RawStrings, &len)

pCurrent = (WCHAR*)RawStrings;
while ( (nLenInChars = wcslen(pCurrent)) != 0 && IdProcessIndex == 0 )
{
    WCHAR* pName;
    pName = pCurrent + nLenInChars + 1;

    if ( wcscmp( pName, L"ID Process" ) == 0)
    {
        IdProcessIndex = _wtoi( pCurrent );
    }

    pCurrent = pName + wcslen( pName ) + 1;
}

// Get data for the "ID Process" counter
WCHAR strIdProcessIndex[32];
_itow( nIdProcessIndex, strIdProcessIndex, 10 );

RegQueryValueExW(HKEY_PERFORMANCE_DATA, strIdProcessIndex, NULL, NULL, (PBYTE)pData, &len)

Trouble is that on some machines (ones with the Windows CE dev kit installed) there is a second perfmon counter with the name “ID Process”, and so the above finds the ID of the wrong counter.

I cant see any way to differentiate between the two other than the order that they are in – at the moment I think my best bet is to take the first counter that I find with a matching name, is there a better option?

(Its not possible to migrate this to .Net or anything like that)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:47:21+00:00Added an answer on May 14, 2026 at 12:47 am

    I realize that this is old, but in case it helps:

    1. Tim is right, parsing the binary data yourself is difficult. Prepare yourself for a world of pain. I’d recommend PDH (encapsulates the registry accesses for you), or if that fails, WMI (though note that WMI is much slower).
    2. You cannot get data for just a performance counter (ID Process, with index 784). You need to get it for the whole object (Process, with index 230).
    3. The IDs for built in objects are guaranteed to be the same on all Windows installations. So if this is the only counter you need, just use 230. 🙂
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 334k
  • Answers 334k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Quartz Compositions do not run on iPhone. The Quartz Composer… May 14, 2026 at 3:22 am
  • Editorial Team
    Editorial Team added an answer If you are putting the expression in a string, you… May 14, 2026 at 3:22 am
  • Editorial Team
    Editorial Team added an answer NLINE=2 s="somestring" sp=" " awk -vn="$NLINE" -vs="$s" -vsp="$sp" 'NR==n{$0=$0 sp… May 14, 2026 at 3:22 am

Related Questions

Background, Part 1 I have a form that collects both frequency and duration from
I'm building an app that given another app mainWindowhandle it collects information about the
I'm working on a Google App Engine project that collects stories submitted by users.
I'm creating a simple app (PHP & MYSQL) that collects information about an event,
I am likely to be working on a few projects soon where I will

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.