The Visual Basic PdhCloseQuery function closes the specified query and all counters related to that query. All resources allocated for the query and its counters are freed. The handles of counters added to this query should be deleted or zeroed and not used after the query they belong to is deleted.
PdhCloseQuery(
ByVal QueryHandle as Long)
as Long
If the function succeeds, it returns a Long integer equal to ERROR_SUCCESS.
If the function fails, the return value is a PDH error status defined in pdhdefs.txt. The following is a possible error value:
Performance Data Helper Overview, Performance Data Functions