c++ - Error with using PdhAddEnglishCounter -


my code:

#include <windows.h> #include <iostream> #include <pdh.h> #pragma comment (lib, "pdh.lib") void main() {     pdh_status status;     hquery query = null;     hcounter counter;     wchar buffer[pdh_max_counter_path];     pdhopenquery(null, null, &query);     wcscpy(buffer, l"\\nto-prog\thread(_total/_total)\context switches/sec");     status = pdhaddenglishcounter(query, buffer, 0, &counter); } 

i have error:

pdh error

english translate:

access point in procedure pdhaddenglishcountera not found in library dll pdh.dll.

if i'm using pdhaddcounter instead of pdhaddenglishcounter, see in status: 0xc0000bc0 (pdh_cstatus_bad_countername). need this?

p.s. i'm using visual studio 2010 on windows xp.

the reason error, as msdn says pdhaddenglishcounter not supported on windows xp

enter image description here

for pdhaddcounter, counter path has correctly localized. refer msdn here. might want consider pdhlookupperfnamebyindex alternative (again, msdn here).

there useful article on ms knowledgebase too.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -