Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Development
Diagnostics
 PdhBrowseCounters function
PdhBrowseCounters function

Applies to: desktop apps only

Displays a Browse Counters dialog box that the user can use to select one or more counters that they want to add to the query.

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

Syntax

PDH_STATUS PdhBrowseCounters(
  __in  PPDH_BROWSE_DLG_CONFIG pBrowseDlgData
);

Parameters

pBrowseDlgData [in]

A PDH_BROWSE_DLG_CONFIG structure that specifies the behavior of the dialog box.

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.

Remarks

Note that the 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 information on using this function, see Browsing Counters.

Examples

For an example, see Browsing Performance Counters.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Pdh.h

Library

Pdh.lib

DLL

Pdh.dll

Unicode and ANSI names

PdhBrowseCountersW (Unicode) and PdhBrowseCountersA (ANSI)

See also

CounterPathCallBack
PDH_BROWSE_DLG_CONFIG
PdhBrowseCountersH

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
List of bugs - Vista+ O/S's      Ascend4nt   |   Edit   |   Show History
Regarding the last user's comments - you don't need elevation, you need to set this flag to false and it should return selections:
bSingleCounterPerAdd = FALSE

The bug makes it so a programmer can't force it to only allow one selection.  It may work elevated, but that makes no sense.
 
Also, the flag 'bWildCardInstances' must ALWAYS be set to TRUE, otherwise it causes crashes in many cases, at least on Windows 7.

Other bugs on Vista+:
- You need to manually set the title, it no longer offers a default (NULL pointer).
- You can't set an initial performance counter to be highlighted.  It is ignored.
- Sometimes the Instances won't show up on the bottom, depending on where you click on the top portion of the dialog box. This causes an invalid Counter path to be returned.
- Windows 7: PDH.DLL and 40 other DLL's are loaded, and STAY loaded once PdhBrowseCounters returns. Manually unloading the DLL's often causes crashes. This may or may not have something to do with .NET 4.0 being present.
Tags What's this?: Add a tag
Flag as ContentBug
Bug on Win7 in that PdhBrowseCounters requires Elevation?      Helge Klein   |   Edit   |   Show History
There seems to be a bug in PdhBrowseCounters. If it is call from a non-elevated process on Windows 7, it always returns an empty string, but the dialog is displayed OK. I have described this in detail here:

http://it-from-inside.blogspot.com/2009/10/found-my-first-bug-in-windows-7-apis.html
Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2012 Microsoft. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker