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

  • Home
  • SEARCH
  • 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
  • 1 View
  • 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

Related Questions

We have a POS apartment leasing iPad app that is used to collect a
I have an air app that collects live data from a user's action and
I am writing app, that collects location data, based on GPS. And i have
I have an android app that repeatedly collects fingerprints from the wifi-networks that are
have an app that finds your GPS location successfully, but I need to be
Have an app that has listings - think classified ads - and each listing
I have an app that needs to read a PDF file from the file
We have an app that needs to access network resources. It's written in VB.Net.
I have an app that is run from a compiled DLL on a web
I have an app that sends multiple Ajax requests simultaneously. I was originally running

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.