Platform SDK: Performance Monitoring |
You can call the PdhBrowseCounters function to display the following dialog box, which lets you browse and select performance counters.
You control the configuration of the dialog box by setting members of the PDH_BROWSE_DLG_CONFIG structure that you pass to PdhBrowseCounters. The szReturnPathBuffer member contains a pointer to a buffer you allocate. The cchReturnPathLength member contains the size of the buffer you allocated. This buffer provides a communication link between your application and the dialog box. If you want to define a callback function to process the counter names returned by the browser, use the CounterPathCallback function.
When the dialog box is first displayed, the default performance object and the default counter will be automatically selected if the data source is specified as current activity. Default performance objects and default counters are not supported if the data source is a log file. To obtain these settings through the PDH interface, call the PdhGetDefaultPerfObject and PdhGetDefaultPerfCounter functions. The default object and counter settings can be retrieved, and not set, through the PDH and registry interfaces.
By calling the PdhSelectDataSource function, you can display a dialog box prompting the user to select whether the data source is real-time or a log file, and, if it is a log file, its name. The following data source dialog is displayed first.
If the user knows the name of the log file, he or she can enter it in the following dialog box. If the log file name is not known, the user can click the ellipsis button in the dialog box to display the following file browser.
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.
You can use PdhSelectDataSource in conjunction with PdhBrowseCounters to allow the user even more performance data input options.