IltmmConvert::SetClosedCaptioningTargetFile Example for C++

// This function does the following:
// 1) Sets a closed captioning target file and saves it in SRT format.
// 2) Retrieves the file and its flag and makes sure it is properly set.
// 3) Sets a closed captioning target file and saves it in TEXT format.
// 4) Retrieves the file and its flag and makes sure it is properly set.

void TestSetClosedCaptioningTargetFile(IltmmConvert *pConvert)
{
   HRESULT hr = S_OK;
   BSTR bstrTargetFileSRT = NULL;
   BSTR bstrTargetFileTEXT = NULL;
   BSTR bstrTargetFile = NULL;
   long Flags = 0;
   bstrTargetFileSRT = SysAllocString(L"c:\\ClosedCaptioning.srt");
   bstrTargetFileTEXT = SysAllocString(L"c:\\ClosedCaptioning.txt");
   
   // Set the closed captioning target file to c:\\ClosedCaptioning.srt and save it in SRT format.
   hr = pConvert->SetClosedCaptioningTargetFile(bstrTargetFileSRT, 0);
   ASSERT( hr == S_OK);
   bstrTargetFile = NULL;
   hr = pConvert->GetClosedCaptioningTargetFile(&bstrTargetFile, &Flags);
   if((hr == S_OK) && (VarBstrCmp(bstrTargetFile, bstrTargetFileSRT, NORM_IGNORECASE | LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_EQ)) && (0==Flags) )
      MessageBox(NULL, TEXT("The Closed Captioning Target File was set properly!"), TEXT("SUCCESS"), MB_OK);
   else
      MessageBox(NULL, TEXT("The Closed Captioning Target File was NOT set properly!"), TEXT("FAILURE"), MB_OK);
   SysFreeString(bstrTargetFile);
   bstrTargetFile = NULL;
   // Set the closed captioning target file to c:\\ClosedCaptioning.txt and save it in TEXT format.
   hr = pConvert->SetClosedCaptioningTargetFile(bstrTargetFileTEXT, ltmmClosedCaptioning_Text);
   ASSERT( hr == S_OK);
   bstrTargetFile = NULL;
   hr = pConvert->GetClosedCaptioningTargetFile(&bstrTargetFile, &Flags);
   if((hr == S_OK) && (VarBstrCmp(bstrTargetFile, bstrTargetFileTEXT, NORM_IGNORECASE | LOCALE_USER_DEFAULT, 0) == static_cast(VARCMP_EQ)) && (ltmmClosedCaptioning_Text==Flags) )
      MessageBox(NULL, TEXT("The Closed Captioning Target File was set properly!"), TEXT("SUCCESS"), MB_OK);
   else
      MessageBox(NULL, TEXT("The Closed Captioning Target File was NOT set properly!"), TEXT("FAILURE"), MB_OK);
   SysFreeString(bstrTargetFile);
   bstrTargetFile = NULL;
   SysFreeString(bstrTargetFileSRT);
   SysFreeString(bstrTargetFileTEXT);
}