Platform SDK: Performance Monitoring

PdhCloseQuery

The PdhCloseQuery function closes all counters contained in the specified query, closes all handles related to the query, and frees all memory associated with the query.

[C++] 
PDH_STATUS PdhCloseQuery(
  HQUERY hQuery  
);
[Visual Basic]
PdhCloseQuery(
  ByVal QueryHandle as Long  
)
as Long

Parameters

[C++] hQuery
[in] A handle to the query to close and delete.
[Visual Basic] QueryHandle
[in] The ID of the query to close and delete. Closing a query closes all the counters associated with the query.

Return Values

If the function succeeds, it returns ERROR_SUCCESS and closes and deletes the query. Otherwise, the function returns a PDH error value.

The following is the possible PDH error value.

Error value Description
PDH_INVALID_HANDLE The query handle is not valid.

[C++] PDH error values are defined in PDHMsg.h.

[Visual Basic] PDH error values are defined in PDHDef.txt.

Remarks

The handles added to this query should be deleted or zeroed and not used after the query they belong to is deleted.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Header: Declared in Pdh.h (C/C++).
  Library: Use Pdh.lib.

See Also

PdhOpenQuery