PtwInfo Example for C++ 5.0 and later

// This sample code is for the AcquirePageEvent handler
ILEADRasterTwain_U * pRasTwain; 
void CRasterTwainSink::OnAcquire ()
{
   ItwExtImageInfo_U * ptwExt = NULL; 
   ILEADRasterVariant_U * Item = NULL; 
   CoCreateInstance(CLSID_LEADRasterVariant_U, NULL, CLSCTX_ALL, 
                                   IID_ILEADRasterVariant_U, (void **)&Item); 

   ::CoCreateInstance (CLSID_twExtImageInfo_U, NULL, CLSCTX_ALL, IID_ItwExtImageInfo_U, (void **)ptwExt); 
   if (ptwExt) 
   {
      ptwExt->put_
NumOfInfos(1); 
      ptwExt->GetptwInfo(0)->put_
InfoID(L_TWEI_BARCODETEXT); 
      ptwExt->GetptwInfo(0)->put_
ItemType(L_TWTY_UINT32); 

      if (!pRasTwain->
GetExtImageInfo(ptwExt)) 
      {
         if (ptwExt->
GetptwInfo(0)->GetCondCode() == L_TWCC_SUCCESS) 
         {
            long lNumOfItems = ptwExt->GetptwInfo(0)->
GetNumOfItems();
            for (int nIndex = 0 ; nIndex < lNumOfItems ; nIndex ++)
            {
               Item = ptwExt->GetptwInfo(0)->
GetItem(nIndex, 0); 
               // Do more processing on the item value
            }
         }
      }
      ptwExt->Release ();
   }

   Item->Release ();
}