PdhOpenQuery Function Home
PdhOpenQuery Function

Creates a new query that is used to manage the collection of performance data.

To use handles to data sources, use the PdhOpenQueryH function.

Syntax

PDH_STATUS PdhOpenQuery(
  __in   LPCTSTR szDataSource,
  __in   DWORD_PTR dwUserData,
  __out  PDH_HQUERY *phQuery
);


Parameters

szDataSource [in]

Null-terminated string that specifies the name of the log file from which to retrieve performance data. If NULL, performance data is collected from a real-time data source.

dwUserData [in]

User-defined value to associate with this query. To retrieve the user data later, call PdhGetCounterInfo and access the dwQueryUserData member of PDH_COUNTER_INFO.

phQuery [out]

Handle to the query. You use this handle in subsequent calls.

Return Value

If the function succeeds, it returns ERROR_SUCCESS.

If the function fails, the return value is a system error code or a PDH error code.

Examples

For an example, see Reading Performance Data from a Log File or Writing Performance Data to a Log File.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderPdh.h
LibraryPdh.lib
DLLPdh.dll
Unicode and ANSI namesPdhOpenQueryW (Unicode) and PdhOpenQueryA (ANSI)

See Also

PdhCloseQuery
PdhGetCounterInfo
PdhIsRealTimeQuery
PdhOpenQueryH
PdhSetDefaultRealTimeDataSource

Send comments about this topic to Microsoft

Build date: 11/12/2009

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View