Finding perfmon counter id via winreg

I have an application that collects Perfmon counter values โ€‹โ€‹through the API open in winreg.h - in order to collect Perfmon counter values, I have to make a call RegQueryValueExWpassing in the Perfmon counter identifier that interests me, and in order to get this identifier, I need to query the registry for the list of Perfmon counter names and go through the search for who is interested

C ++ is not my choice language, so the following example is a shaky example, perhaps with a lot 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)

, ( Windows CE dev) perfmon "ID Process", .

, , , - , , , , ?

( .Net - )

+2
2

, , , :

  • , . . PDH ( ), , WMI ( , WMI ).
  • (ID Process, 784). (Process, 230).
  • Windows. , , , 230.:)
+2

? , , ?

, ? (, OpenProcess )

( .Net - )

API PDH (, PdhOpenQuery) COM, WMI? ++.

, , , ID Process - (, WoW16/64 ?) . AdminstrativeTools\Performance MMC?

0

All Articles