Platform SDK: Performance Monitoring |
The PdhOpenLog function opens the specified log file for reading or writing.
PDH_STATUS PdhOpenLog( LPCTSTR szLogFileName, DWORD dwAccessFlags, LPDWORD lpdwLogType, HQUERY hQuery, DWORD dwMaxSize, LPCTSTR szUserCaption, HLOG *phLog );
Value | Meaning |
---|---|
PDH_LOG_READ_ACCESS | A new log file is opened for a read operation. |
PDH_LOG_WRITE_ACCESS | A new log file is opened for a write operation. |
PDH_LOG_UPDATE_ACCESS | An existing log file is opened for a write operation. |
The value selected from the previous table can be combined using the OR operator with one of the following create access flags.
Value | Meaning |
---|---|
PDH_LOG_CREATE_NEW | A new log file with the specified name is created. |
PDH_LOG_CREATE_ALWAYS | A new log file with the specified name is created and any existing log file with the same name is erased. |
PDH_LOG_OPEN_EXISTING | An existing log file with the specified name is opened. If a log file with the specified name does not exist, this is equal to PDH_LOG_CREATE_NEW. |
PDH_LOG_OPEN_ALWAYS | An existing log file with the specified name is opened or a new log file with the specified name is created. |
Value | Meaning |
---|---|
PDH_LOG_TYPE_UNDEFINED | Undefined log file format. |
PDH_LOG_TYPE_CSV | Text files containing column headers in the first line, and individual data samples in each subsequent line. |
PDH_LOG_TYPE_TSV | Same as PDH_LOG_TYPE_CSV. |
PDH_LOG_TYPE_BINARY | Binary log file format. Includes circular log files. |
PDH_LOG_TYPE_PERFMON | Perfmon log file format. |
If the function succeeds, it returns ERROR_SUCCESS.
If the function fails, the return value is a PDH error status defined in PDHMsg.h. The following are possible error values.
Error value | Description |
---|---|
PDH_INVALID_ARGUMENT | An argument is not correct or is incorrectly formatted. |
When using this function to write performance data to a log file, a query must first be opened using PdhOpenQuery.
There must be a currently opened query, and the desired counters must be added to it, before this function is called.
Note that log files in the Perfmon format can only be opened for reading.
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.
PdhOpenQuery, PdhUpdateLog, PdhUpdateLogFileCatalog,PdhGetLogFileSize