PdhOpenQueryA function (pdh.h)

Creates a new query that is used to manage the collection of performance data.

To use handles to data sources, use the PdhOpenQueryH function.

Syntax

PDH_FUNCTION PdhOpenQueryA(
  [in]  LPCSTR     szDataSource,
  [in]  DWORD_PTR  dwUserData,
  [out] PDH_HQUERY *phQuery
);

Parameters

[in] szDataSource

Null-terminated string that specifies the name of the log file from which to retrieve performance data. If NULL, performance data is collected from a real-time data source.

[in] dwUserData

User-defined value to associate with this query. To retrieve the user data later, call PdhGetCounterInfo and access the dwQueryUserData member of PDH_COUNTER_INFO.

[out] phQuery

Handle to the query. You use this handle in subsequent calls.

Return value

If the function succeeds, it returns ERROR_SUCCESS.

If the function fails, the return value is a system error code or a PDH error code.

Remarks

Note

The pdh.h header defines PdhOpenQuery as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header pdh.h
Library Pdh.lib
DLL Pdh.dll

See also

PdhCloseQuery

PdhGetCounterInfo

PdhIsRealTimeQuery

PdhOpenQueryH

PdhSetDefaultRealTimeDataSource