PdhEnumObjectItems returning PDH_CSTATUS_NO_MACHINE

PdhEnumObjectItems returning PDH_CSTATUS_NO_MACHINE

Post by ZW5udWk3N » Sat, 03 Nov 2007 23:36:01


I'm calling PdhEnumObjectItems (indirectly through python's win32 module).
When the calls are run as an admin user they work just fine, no problems.
When the calls are made through a regular domain user account, they fail with
the PDH_CSTATUS_NO_MACHINE error message (this is durning the first call to
get the buffer size). I'm not sure what this error message actually means.
The code is always trying to connect to the local machine (by not specify a
machine in the path to the counter) so I don't understand why it would ever
return PDH_CSTATUS_NO_MACHINE. What does that error code really mean? What
can I do to make this call succeed?
 
 
 

1. Problem with then PdhEnumObjectItems API on LongHorn

2. Can I call PdhEnumObjectItems in console mode?

Windows XP SP1, VC++ 6.0, Platform SDK

Hi all,

I want to use PDH to enum processes on local machine. And I wrote the
following function.

void GetProcesses(void)
{
CHAR CounterList[4096];
CHAR InstanceList[4096];
DWORD dwCounterLen = 4096;
DWORD dwInstanceLen = 4096;

PDH_STATUS status = PdhEnumObjectItems(
NULL,
NULL,
"Process",
CounterList,
&dwCounterLen,
InstanceList,
&dwInstanceLen,
PERF_DETAIL_WIZARD,
0);

<snip>
}

If I call this function in main() in a console application, "InstanceList"
will contain:
Idle
System
smss
csrss
winlog
servic
lsass
svchos
svchos
svchos
<snip>

But if I call this function in WinMain() in a Win32 application, I'll get:
Idle
System
smss
csrss
winlogon
services
lsass
svchost
svchost
svchost
<snip>

Obviously some of the process names get by console application are wrong.
Can PDH function work well with console mode applications?

Thanks,
Min

3. PDH.dll PdhEnumObjectItems() to get running processes?

4. what value does lack of return or empty "return;" return

5. query suppose to return all records but returns multiple or no ent

6. SQL returns only 35 records when it should return 50,000?

7. count fun returns with no data, how can i get it to return zer

8. How to return a value from an Oracle select and return into in

9. EnumDisplaySettings returns Error 126 for what EnumDisplayDevices returned

10. What's the meaning of return value -1 of StartDoc function and GetLastError return 0?

11. PostMessage return FALSE and GetLastError() return S_OK

12. GetTextMetrics returns 0, GetLastError returns 0

13. (newbie) Get the return value from a stored proc (return @aValue)

14. web methods returning boolean : always returns false

15. Method Call hangs when null is returned as string return value