PtwInfo Example for C++ 5.0 and later

// This sample code is for the AcquirePageEvent handler
// For another
ILEADRasterTwain * pRasTwain; 
void CRasterTwainSink::OnAcquire ()
{
   ItwExtImageInfo * ptwExt = NULL; 
   ILEADRasterVariant * Item = NULL; 
   CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL, 
                                   IID_ILEADRasterVariant, (void **)&Item); 

   ::CoCreateInstance (CLSID_twExtImageInfo, NULL, CLSCTX_ALL, IID_ItwExtImageInfo, (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 ();
}