Writing Windows Media Files for C

You do not need do use software certificates on computers with Windows Media 9 Components or later. For more information, please go to Windows Media Support.

To write Windows Media files on computers without Windows Media 9 components, an application must provide a software certificate, also called a key, at run time. For details on obtaining the certificate, see the Windows Media Format SDK. An application provides its certificate to the ltmmCapture or ltmmConvert objects by calling the IltmmCapture::put_WMCertificate or IltmmConvert::put_WMCertificate object methods. The certificate is obtained by calling the Windows Media Format SDK method WMCreateCertificate. The method returns a pointer to the certificate that was created. To build an application, include Wmsdkidl.h for the prototype for WMCreateCertificate, and link to the Wmstub.lib that you received from Microsoft.

The following code example illustrates the basic steps in this process:

// define helper macros for using interfaces under C

To write Windows Media files, an application must provide a software certificate, also called a key, at run time. For details on obtaining the certificate, see the Windows Media Format SDK. An application provides its certificate to the ltmmCapture or ltmmConvert objects by calling the IltmmCapture::put_WMCertificate or IltmmConvert::put_WMCertificate object methods. The certificate is obtained by calling the Windows Media Format SDK method WMCreateCertificate. The method returns a pointer to the certificate that was created. To build an application, include Wmsdkidl.h for the prototype for WMCreateCertificate, and link to the Wmstub.lib that you received from Microsoft. The following code example illustrates the basic steps in this process.

// define helper macros for using interfaces under C
#ifndef COBJMACROS
   #define COBJMACROS
#endif

// include the LEAD Multimedia TOOLKIT header
#include "ltmm.h" 

// include the Windows Media SDK header
#include "wmsdkidl.h" 

// EnableWindowsMedia
// enables the convert object to write Windows Media file formats
// pConvert – IltmmConvert interface pointer
L_MULTIMEDIATEX_API HRESULT EnableWindowsMedia_Example (IltmmConvert* pConvert)
{
   HRESULT hr; 
   IUnknown* punkCert; 

   // create Windows Media Certificate
   hr = WMCreateCertificate(&punkCert); 
   if(SUCCEEDED(hr)) 
   {
      // assign the certificate to the convert object
      hr = IltmmConvert_put_WMCertificate (pConvert, punkCert); 
      IUnknown_Release(punkCert); 
   }   
   return hr; 
}