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
);
 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:
Performance Data Helper Overview, Performance Data Functions, , PdhCloseQuery, PdhGetCounterInfo