Platform SDK: Performance Monitoring

PdhSelectDataSource

The PdhSelectDataSource function displays a dialog window that prompts the user to specify where the performance data will be collected.

PDH_STATUS PdhSelectDataSource(
  HWND hWndOwner,        
  DWORD dwFlags,         
  LPTSTR szDataSource,   
  LPDWORD pcchBufferLength 
);

Parameters

hWndOwner
[in] The owner of the dialog window that is displayed. This can be NULL if there is no owner.
dwFlags
[in] The dialog windows that will be displayed to prompt for the data source. This parameter can be one of the following values.
Value Meaning
PDH_FLAGS_FILE_BROWSER_ONLY Display the file browser only.
0 Display the data source selection dialog containing a button that can be clicked to display the file browser.

This function can prompt for the data source in two ways. If the value of this parameter is zero, then a dialog is displayed prompting the user to select performance data input from either a log file or a real-time source. If the user specified that data is to be collected from a log file, a file browser is displayed for the user to specify the name and location of the log file.

If the value of this parameter is PDH_FLAGS_FILE_BROWSER_ONLY, the file browser only will be displayed. This flag would be set when this function is used solely to prompt for the name and location of a log file.

szDataSource
[out] A pointer to a buffer that receives the description of the data source. The value of the parameter will be either a null-terminated string containing either the name of a log file containing the performance data, or NULL if the performance data is taken from a real-time data source.
pcchBufferLength
[in/out] The maximum length, in characters, of the szDataSource buffer.

Return Values

If the function succeeds, it returns ERROR_SUCCESS.

If the function fails, the return value is an error status defined in PDHMsg.h. The following are possible error values.

Error value Description
PDH_INVALID_ARGUMENT The length of the buffer passed in the pcchBufferLength is not equal to the actual length of the szDataSource parameter.
PDH_MEMORY_ALLOCATION_FAILURE A zero-length buffer was passed in the szDataSource parameter.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Header: Declared in Pdh.h.
  Library: Use Pdh.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows 2000.

See Also

PdhIsRealTimeQuery