IltmmCaptureSubTypes::get_Count Example for C

void IltmmCaptureSubTypes_get_Count_Example (IltmmCapture* pCapture)
{
   IltmmCaptureSubTypes* pVideoCapSubTypes;
   IltmmCaptureSubType*  pCapSubType;
   long lCount, lSel, i;
   VARIANT_BOOL bVar;
   BSTR bstrName = NULL, bstrFriendName = NULL;


   IltmmCapture_get_VideoCaptureSubTypes(pCapture, (IltmmCaptureSubTypes**)&pVideoCapSubTypes);
   
   IltmmCaptureSubTypes_get_Count(pVideoCapSubTypes, &lCount);

   if (lCount > 0)
   {
      for (i = 0; i < lCount; i++)
      {
         IltmmCaptureSubTypes_Item(pVideoCapSubTypes, i, &pCapSubType);

         if (i == 1)
         {
            IltmmCaptureSubType_get_Name(pCapSubType, &bstrName);

            IltmmCaptureSubType_get_FriendlyName(pCapSubType, &bstrFriendName);

            IltmmCaptureSubType_get_Selected(pCapSubType, &bVar);

            if (bVar == VARIANT_TRUE)
               IltmmCaptureSubType_put_Selected(pCapSubType, VARIANT_FALSE);
         }

         IltmmCaptureSubType_Release(pCapSubType);
      }

      IltmmCaptureSubTypes_get_Selection(pVideoCapSubTypes, &lSel);

      if (lSel != 1)
      {
         IltmmCaptureSubTypes_Find(pVideoCapSubTypes, bstrName, &lSel);
         IltmmCaptureSubTypes_put_Selection(pVideoCapSubTypes, lSel);
      }

      SysFreeString(bstrName);
      SysFreeString(bstrFriendName);
   }

   IltmmCaptureSubTypes_Release(pVideoCapSubTypes);
}