Capability Example for C++ 5.0 and later

ILEADRasterTwain * pltRasTwain;
   long lCount; 
   long lCapability;   
   ILEADRasterVariant * CapVal = NULL; 
   CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, 
                                   IID_ILEADRasterVariant, (void **)&CapVal); 

   ICapability * pCapability = NULL; 
   ICapabilityOneValue * pCapOV = NULL; 

   ::CoCreateInstance (CLSID_LEADRasterTwainCapability, NULL, CLSCTX_ALL, IID_ICapability, (void **)&pCapability); 
   pCapability->QueryInterface (IID_ICapabilityOneValue, (void **)&pCapOV); 

   pltRasTwain->get_
CapsCount(&lCount); 
   for (long n = 0 ; n < lCount ; n++)
   {
      pltRasTwain->get_
Capability(n, &lCapability); 
      // Check for capability and do other processing

      if (lCapability == L_ICAP_XFERMECH) 
      {
         pCapability->
EnableMethodErrors = FALSE; 
         pCapability->
Capability = L_ICAP_XFERMECH; 
         pCapability->
ConType = L_TWON_ONEVALUE; 

         CapVal->Type = VALUE_USHORT; 
         CapVal->LongValue = L_TWSX_FILE; 

         pCapOV->put_
OneValItemType(L_TWTY_UINT16); 
         pCapOV->put_
OneValCapValue(CapVal); 

         pltRasTwain->
SetCapability(pCapability, L_LTWAIN_CAPABILITY_SET); 
      }
   }

   CapVal->Release();