The Visual Basic PdhOpenQuery function creates and initializes a unique query structure that is used to manage the collection of performance data.
PdhOpenQuery(
ByRef QueryHandle as Long)
as Long
If the function succeeds, it returns a Long integer equal to ERROR_SUCCESS and a new handle in the QueryHandle variable.
If the function fails, the return value is a PDH error status defined in pdhdefs.txt. The following are possible error values:
Performance Data Helper Overview, Performance Data Functions