Enabling Logging
Windows Media Device Manager provides a logging object that can save information to a text file at run time. Developers of both applications and service providers can use this object to store messages in a log file while their application or service provider is running. This object is especially useful when handling DRM-protected files, because Windows Media Device Manager will not allow you to attach a debugger to a process that is handling DRM-protected files.
The logger is a COM object with the class ID CLSID_WMDMLogger that exposes one interface, IWMDMLogger. Components do not need a certificate to use the logging object.
By default, Windows Media Device Manager maintains a log file, regardless of whether an application uses IWMDMLogger. This log file is a simple text file, and each entry includes an entry preceded by a time stamp in the format YYYYMMDDHHMMSS, using 24-hour local time. Windows Media Device Manager logs all API calls, along with any entries you add by calling IWMDMLogger messages. All log file entries are appended to the file until Reset is called, or the file exceeds its maximum size. The file is closed automatically after each logging operation. The same log file is used for application entries and system entries.
The following steps show how to use the logging object:
- Include wmdmlog.h in your project.
- Create a logging object by calling CoCreateInstance(CLSID_WMDMLogger) and requesting the IWMDMLogger interface. Assign the interface pointer to a global variable.
- Verify that logging is enabled by calling IWMDMLogger::IsEnabled; if it is not, enable it by calling IWMDMLogger::Enable.
- Specify a custom log file name and size. This is done by calling IWMDMLogger::SetLogFileName and IWMDMLogger::SetSizeParams.
- At points in your code where you want to make an entry in the log, call either IWMDMLogger::LogDword to log strings containing variables (this method is similar to wsprintf in the way it allows you to format a string containing a variable value), or call IWMDMLogger::LogString to log constant strings.
For example code, see the reference pages for the methods of IWMDMLogger.
See Also