Capability Example for C++ 5.0 and later

ILEADRasterTwain_U * pltRasTwain;
long lCount; 
long lCapability;   
ILEADRasterVariant_U * CapVal = NULL; 
CoCreateInstance(CLSID_LEADRasterVariant_U, NULL, CLSCTX_ALL, 
						   IID_ILEADRasterVariant_U, (void **)&CapVal); 
CoCreateInstance(
	   CLSID_LEADRasterTwain_U, 
	   NULL, 
	   CLSCTX_ALL, 
	   IID_ILEADRasterTwain_U, 
	   (void**)&pltRasTwain);

ICapability_U * pCapability = NULL; 
ICapabilityOneValue_U * pCapOV = NULL; 

::CoCreateInstance (CLSID_LEADRasterTwainCapability_U, NULL, CLSCTX_ALL, IID_ICapability_U, (void **)&pCapability); 
pCapability->QueryInterface (IID_ICapabilityOneValue_U, (void **)&pCapOV); 

pltRasTwain->InitSession((long)GetSafeHwnd());
pltRasTwain->SelectSource();
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; 

		//Set the transfer mechanism to file
		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();