How to Set DVR Buffer Locations on Multiple Physical Disks (C++)

The following method for C++ shows how to get the DVR Sink object from the ltmmPlayControl object and use it to set DVR buffer location settings on physical disks C: and D:.

void SetDVRBufferSettings(IltmmPlay *pPlay)
{
   IUnknown *punk = NULL;
   HRESULT hr = pPlay->GetSubObject(ltmmPlay_Object_SourceFilter, &punk);
   
   if(SUCCEEDED(hr) && NULL != punk)
   {
      ILMDVRSink *pDvrSink;
      hr = punk->QueryInterface(IID_ILMDVRSink, (LPVOID*)&pDvrSink);
      punk->Release();
      
      if (SUCCEEDED(hr))
      {
          // Tell sink we are starting to change settings 
         pDvrSink->StartChangingAttributes();

          // Set Two locations 
         pDvrSink->put_FolderCount(2);
         pDvrSink->put_BaseName(TEXT("Capture.LBL"));

         // Set folder 1 location
         pDvrSink->put_FolderName(0, TEXT("C:\\Temp\\DVR"));

         // Set folder 1 file count to 2, each set to 16MB max file size
         pDvrSink->SetBufferSize(0, 2, 16384000);

         // Set folder 2 location
         pDvrSink->put_FolderName(0, TEXT("D:\\Temp\\DVR"));

         // Set folder 2 file count to 4, each set to 8MB max file size
         pDvrSink->SetBufferSize(1, 4, 8192000);

          // Tell sink to apply the changes 
         pDvrSink->StopChangingAttributes(VARIANT_FALSE);
         
          // Release interface and free strings 
         pDvrSink->Release();
      }
   }
}