Platform SDK: Performance Monitoring

Setting a Time Range for a Query

If your data source is a log file, you have the option of defining a time range for a query, which will determine the period of time during which performance data will be collected from the log file. You use the PdhSetQueryTimeRange function to do this. PdhSetQueryTimeRange is not used for queries that collect performance data from real-time data sources.

PdhSetQueryTimeRange sets the start and stop times for the query to the 64-bit (LONGLONG) beginning and ending time values in the PDH_TIME_INFO structure passed in as the second parameter. The standard method for creating these LONGLONG time range values is the following.

  1. Allocate a SYSTEMTIME structure and initialize the fields with the desired time value.
  2. Convert the SYSTEMTIME structure time values to FILETIME structure time values by calling SystemTimeToFileTime.
  3. Cast the FILETIME structure as a LONGLONG value, keeping in mind the structure member padding conventions of your platform and compiler.
  4. Copy the LONGLONG value to the appropriate field in the PDH_TIME_INFO structure.

If you want to obtain the time range of all of the performance data contained in a log file, use the PdhGetDataSourceTimeRange function. PdhGetDataSourceTimeRange returns this information in a PDH_TIME_INFO structure.