PdhOpenQuery 

The PdhOpenQuery function creates and initializes a unique query structure that is used to manage collection of performance data.

PDH_STATUS PdhOpenQuery(

    IN LPVOID pReserved,

// reserved

    IN DWORD dwUserData,

// a value associated with this query

    IN HQUERY *phQuery

// pointer to a buffer that will receive the query handle

   );

 

 

Parameters

pReserved

Reserved. Must be NULL.

dwUserData

A user-defined DWORD value that is to be associated with this query. You can call PdhGetCounterInfo50SEJT to retrieve the user data value for the query in which a counter resides.

phQuery

A pointer to the buffer to receive the handle to the query that is created.

 

Return Values

If the function succeeds, it returns ERROR_SUCCESS, creates a new query, and returns the handle to the query in the buffer pointed to by phQuery.

If the function fails, the return value is a PDH error status defined in PDHMSG.H. The following are possible error values:

PDH_INVALID_ARGUMENT

One or more arguments are invalid.

PDH_MEMORY_ALLOCATION_FAILURE

A memory buffer could not be allocated.

 

See Also

PdhCloseQuery, PdhGetCounterInfo