DVD Source for C

void SetDVDSettings()
{
   // Create the converter object
   IltmmConvert* pConvert; 
   IUnknown* punk; 
   IltmmDVDSource* pDVDSource; 

   HRESULT hr = CoCreateInstance(&CLSID_ltmmConvert, NULL, CLSCTX_INPROC_SERVER, &IID_IltmmConvert, (void**) &pConvert); 
   if(FAILED(hr)) 
   {
      return; 
   }

   // Force the DVD source to be used
   IltmmConvert_put_UseDVDSource(pConvert, VARIANT_TRUE); 

   // Set the source DVD image
   IltmmConvert_put_SourceFile(L"C:\\DVDImage\\VIDEO_TS\\VIDEO_TS.IFO");

   IltmmConvert_put_TargetFile(pConvert, L"C:\\DVDImage.avi");

   // Get the DVD source interface
   IltmmConvert__getSubObject(pConvert, ltmmConvert_Object_SourceFilter, &punk); 
   if (punk) 
   {   
      IUnknown_QueryInterface(punk, &IID_IltmmDVDSource, (void**)&pDVDSource); 

      if (pDVDSource) 
      {
         IltmmDVDTitle *pTitle; 
         long lCount; 
         long lVal; 
         VARIANT_BOOL vbVal; 
         double dVal; 
         BSTR strPlayList;
         int i;

         // Select the mian title in the dics
         IltmmDVDSource_get_Selected (pDVDSource, &lVal);
         if (lVal != ltmmDVDSource_Main_Selected)
            IltmmDVDSource_put_Selected(pDVDSource, ltmmDVDSource_Main_Selected);

         // Get the disc duration
         IltmmDVDSource_get_TotalDuration (pDVDSource, &dVal);
         // Do something with the value

         // Get the selected title duration
         IltmmDVDSource_get_SelectedDuration (pDVDSource, &dVal);
         // Do something with the value

         // Get the play list settings
         IltmmDVDSource_get_PlayList(pDVDSource, &strPlayList);
         // You can save this to a file and restore the settings later

         // Restore the playlist settings
         IltmmDVDSource_put_PlayList(pDVDSource, strPlayList);

         // Free the string
         SysFreeString(strPlayList);
                  
         // Get the title count in the disc
         IltmmDVDSource_get_TitleCount (pDVDSource, &lCount);
         for (i = 0; i < lCount; i++)
         {
            // Get the title interface
            IltmmDVDSource_GetTitle(pDVDSource, i, &pTitle);
            if (pTitle)
            {              
               // Get the X aspect
               IltmmDVDTitle_get_AspectX (pTitle, &lVal);
               // Do something with the value

               // Get the Y aspect
               IltmmDVDTitle_get_AspectY (pTitle, &lVal);
               // Do something with the value

               // Get if the title is a film mode or camera mode
               IltmmDVDTitle_get_IsFilmMode (pTitle, &vbVal);
               // Do something with the value

               // Get if there is user data in line 21, field 1
               IltmmDVDTitle_get_Line21Field1InGOP (pTitle, &vbVal);
               // Do something with the value

               // Get if there is user data in line 21, field 2
               IltmmDVDTitle_get_Line21Field2InGOP (pTitle, &vbVal);
               // Do something with the value

               // Get the compression 
               IltmmDVDTitle_get_Compression (pTitle, &lVal);
               // Do something with the value

               // Get the X source resolution
               IltmmDVDTitle_get_SourceResolutionX (pTitle, &lVal);
               // Do something with the value

               // Get the Y source resolution
               IltmmDVDTitle_get_SourceResolutionY (pTitle, &lVal);
               // Do something with the value

               // Get the Frame Height
               IltmmDVDTitle_get_FrameHeight (pTitle, &lVal);
               // Do something with the value

               // Get the Frame Rate
               IltmmDVDTitle_get_FrameRate (pTitle, &lVal);
               // Do something with the value

               // Get if the source is letter boxed
               IltmmDVDTitle_get_IsSourceLetterboxed (pTitle, &vbVal);
               // Do something with the value

               // Get if the picture can be shown as letterbox 
               IltmmDVDTitle_get_LetterboxPermitted (pTitle, &vbVal);
               // Do something with the value

               // Get if the picture can be shown as pan-scan
               IltmmDVDTitle_get_PanscanPermitted (pTitle, &vbVal);
               // Do something with the value

               // Get the title duration
               IltmmDVDTitle_get_TotalDuration (pTitle, &dVal);
               // Do something with the value

               // Select all title chapters
               IltmmDVDTitle_get_Selected (pTitle, &lVal);
               if (lVal != ltmmDVDSource_Selected)
                  IltmmDVDTitle_put_Selected (pTitle, ltmmDVDSource_Selected);

               // Get the selected chapter duration
               IltmmDVDTitle_get_SelectedDuration (pTitle, &dVal);
               // Do something with the value

               // Get the audio stream count in the title
               IltmmDVDTitle_get_AudioStreamCount (pTitle, &lVal);
               if (lVal > 0)
               {
                  IltmmDVDAudioStream* pAudioStream;

                  // Select the first audio stream
                  IltmmDVDTitle_get_SelectedAudioStream (pTitle, &lVal);
                  if (lVal == -1)
                     IltmmDVDTitle_put_SelectedAudioStream (pTitle, 0);

                  // Get the first audio stream
                  IltmmDVDTitle_GetAudioStream (pTitle, 0, &pAudioStream);
                  if (pAudioStream)
                  {
                     // Select the audio stream
                     IltmmDVDAudioStream_get_Selected (pAudioStream, &vbVal);
                     if (vbVal == VARIANT_FALSE)
                        IltmmDVDAudioStream_put_Selected (pAudioStream, VARIANT_TRUE);

                     // Get the application mode
                     IltmmDVDAudioStream_get_AppMode (pAudioStream, &lVal);
                     // Do something with the value

                     // Get the application mode data
                     IltmmDVDAudioStream__get_AppModeData (pAudioStream, &lVal);
                     // Do something with the value

                     // Get the auido format
                     IltmmDVDAudioStream_get_AudioFormat (pAudioStream, &lVal);
                     // Do something with the value

                     // Get the number of channels
                     IltmmDVDAudioStream_get_Channels (pAudioStream, &lVal);
                     // Do something with the value

                     // Get the frequency
                     IltmmDVDAudioStream_get_Frequency (pAudioStream, &lVal);
                     // Do something with the value

                     // Get the language
                     IltmmDVDAudioStream_get_Language (pAudioStream, &lVal);
                     // Do something with the value

                     // Get the language extension
                     IltmmDVDAudioStream_get_LanguageExtension (pAudioStream, &lVal);
                     // Do something with the value

                     // Get the quantization
                     IltmmDVDAudioStream_get_Quantization (pAudioStream, &lVal);
                     // Do something with the value
                     
                     // Free the pointer
                     IltmmDVDAudioStream_Release(pAudioStream);
                  }
               }


               // Get the subpicture stream count
               IltmmDVDTitle_get_SubpictureStreamCount (pTitle, &lVal);
               if (lVal > 0)
               {
                  IltmmDVDSubpictureStream* pSubpictureStream;

                  // Select the first subpicture stream
                  IltmmDVDTitle_get_SelectedSubpictureStream (pTitle, &lVal);
                  if (lVal == -1)
                     IltmmDVDTitle_put_SelectedSubpictureStream (pTitle, 0);

                  // Get the first subpicture stream
                  IltmmDVDTitle_GetSubpictureStream (pTitle, 0, &pSubpictureStream);

                  if (pSubpictureStream)
                  {
                     // Select the subpicture stream
                     IltmmDVDSubpictureStream_get_Selected (pSubpictureStream, &vbVal);
                     if (vbVal == VARIANT_FALSE)
                        IltmmDVDSubpictureStream_put_Selected (pSubpictureStream, VARIANT_TRUE);

                     // Get the coding mode
                     IltmmDVDSubpictureStream_get_CodingMode (pSubpictureStream, &lVal);
                     // Do something with the value

                     // Get the langauge
                     IltmmDVDSubpictureStream_get_Language (pSubpictureStream, &lVal);
                     // Do something with the value

                     // Get the language extension
                     IltmmDVDSubpictureStream_get_LanguageExtension (pSubpictureStream, &lVal);
                     // Do something with the value

                     // Get the type
                     IltmmDVDSubpictureStream_get_Type (pSubpictureStream, &lVal);
                     // Do something with the value

                     // Free the pointer
                     IltmmDVDSubpictureStream_Release(pSubpictureStream);
                  }
               }

               // Get the chapter count
               IltmmDVDTitle_get_ChapterCount (pTitle, &lVal);
               if (lVal > 0)
               {
                  // Get the first chapter
                  IltmmDVDChapter* pChapter;
                  IltmmDVDTitle_GetChapter (pTitle, 0, &pChapter);

                  // Get the chapter duration
                  IltmmDVDChapter_get_Duration(pChapter, &dVal);

                  // Get if the chapter is selected
                  IltmmDVDChapter_get_Selected (pChapter, &vbVal);
                  if (vbVal == VARIANT_FALSE)
                     IltmmDVDChapter_put_Selected (pChapter, VARIANT_TRUE);

                  // Free the pointer
                  IltmmDVDChapter_Release(pChapter);
               }

               IltmmDVDTitle_Release(pTitle);
            }
         }
         IltmmDVDSource_Release(pDVDSource);
      }
      IUnknown_Release(punk);
   }
}