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.

Syntax

PDH_FUNCTION PdhCloseQuery(
  PDH_HQUERY hQuery
);

Parameters

hQuery

Handle to the query to close. This handle is returned by the PdhOpenQuery function.

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 is a possible value.

Return code Description
PDH_INVALID_HANDLE
The query handle is not valid.

Remarks

Do not use the counter handles associated with this query after calling this function.

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

PdhCloseQuery(
  ByVal QueryHandle as Long  
)
as Long

Examples

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

Requirements

   
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

PdhOpenQuery