Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Diagnostics
 PdhCollectQueryData function
PdhCollectQueryData function

Applies to: desktop apps only

Collects the current raw data value for all counters in the specified query and updates the status code of each counter.

Syntax

PDH_STATUS PdhCollectQueryData(
  __inout  PDH_HQUERY hQuery
);

Parameters

hQuery [in, out]

Handle of the query for which you want to collect data. The PdhOpenQuery function returns this handle.

Return value

If the function succeeds, it returns ERROR_SUCCESS. Otherwise, the function returns a system error code or a PDH error code.

The following are possible values.

Return codeDescription
PDH_INVALID_HANDLE

The query handle is not valid.

PDH_NO_DATA

The query does not currently contain any counters. The query may not contain data because the user is not running with an elevated token (see Limited User Access Support).

 

Remarks

Call this function when you want to collect counter data for the counters in the query. PDH stores the raw counter values for the current and previous collection.

If you want to retrieve the current raw counter value, call the PdhGetRawCounterValue function. If you want to compute a displayable value for the counter value, call the PdhGetFormattedCounterValue function. If the counter path contains a wildcard for the instance name, instead call the PdhGetRawCounterArray and PdhGetFormattedCounterArray functions, respectively.

When PdhCollectQueryData is called for data from one counter instance only and the counter instance does not exist, the function returns PDH_NO_DATA. However, if data from more than one counter is queried, PdhCollectQueryData may return ERROR_SUCCESS even if one of the counter instances does not yet exist. This is because it is not known if the specified counter instance does not exist, or if it will exist but has not yet been created. In this case, call PdhGetRawCounterValue or PdhGetFormattedCounterValue for each of the counter instances of interest to determine whether they exist.

The following shows the syntax if calling this function from Visual Basic.

PdhCollectQueryData(
  ByVal QueryHandle as Long  
)
as Long

QueryHandle

[in] Identifies the query whose data you want to collect. The PdhVbOpenQuery function returns the identifier.

Examples

For an example, see Browsing Performance Counters or Reading Performance Data from a Log File.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Pdh.h

Library

Pdh.lib

DLL

Pdh.dll

See also

PdhGetFormattedCounterValue
PdhGetRawCounterValue

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
PDH_NO_DATA returned under Windows Vista upwards      Andrew de Quincey   |   Edit   |   Show History
I've been seeing this call returns PDH_NO_DATA under windows vista upwards when reading a log file from disk. Judging by Google, lots of other people have too. I also found the number and contents of log entries tended to vary depending on when I called it. $0$0 $0 $0After watching what relog.exe does, I found out if you add this chunk of code after you've added your counters to the query, but before the first call to PdhCollectQueryData:$0 $0$0 $0 $0 $0 UInt32 numEntries = 1;$0 $0 PDH_TIME_INFO timeInfo = new PDH_TIME_INFO();$0 $0 UInt32 bufSize = 24;$0 $0 PdhGetDataSourceTimeRange(perfmonFilename, ref numEntries, ref timeInfo, ref bufSize);$0 $0 PdhSetQueryTimeRange(hquery, ref timeInfo);$0 $0 $0$0 $0 $0(I'm working in c#, but it should be easily translatable to c++ etc)$0 $0$0 $0
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker