大网数据广告活动
性能与资源

Browsing Counters

· 52CE 我爱测

To display a dialog box that lists the performance objects and counters defined on the computer, call the PdhBrowseCounters function.

To display a dialog box that lists the performance objects and counters defined on the computer, call the PdhBrowseCounters function. The dialog box lets the user browse and select performance counters. You use the PDH_BROWSE_DLG_CONFIG structure to specify the configuration of the dialog box. For example, you can configure the dialog to return one selection or multiple selections.

On input, the szReturnPathBuffer member contains the default performance object and counter that is selected in the dialog box. On output, the buffer contains the performance object and counter that the user selected. You can also use the pCallBack member to specify a callback function to process the counter names returned by the dialog box.

Note that this dialog box can return PDH_DIALOG_CANCELLED if bSingleCounterPerDialog is FALSE and the user clicks the Close button, so your error handling would have to account for this.

For an example that uses the PdhBrowseCounters function, see Browsing Performance Counters.

To retrieve a list of performance objects on the computer, you can also call the PdhEnumObjects function. To retrieve a list of counters and instances for a performance object, call the PdhEnumObjectItems function. You can also use these functions to identify the performance objects and counters contained in a log file. Repeated calls to PdhEnumObjectItems will return the same list of counters and instances until you call PdhEnumObjects to refresh the list of performance objects first. For an example that enumerates objects and counters, see Enumerating Process Objects.

Selecting the data source

You can use PdhSelectDataSource in conjunction with PdhBrowseCounters to prompt the user to select whether the data source is in real-time or from a log file, and, if it is a log file, its name. If you do not want the data source dialog to be displayed, you can call PdhSelectDataSource to display only the file browser catalog. To do this, specify PDH_FLAGS_FILE_BROWSER_ONLY as the second parameter of the call to PdhSelectDataSource.

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 07/14/2025
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。