Example 5: Output numeric and string capability values

Top  Previous  Next

Example :  Enumerate all of a Source's capabilities and output the numeric and string values of the capabilities

 

#include "cdtwain.h"

#include <iostream>

 

using namespace DTWAIN;

using namespace std; // for <iostream>

 

int main( )

{

  // Initialize DTWAIN - return if initialization does not work

  DTwainInterface TI;

  if ( !TI.IsValid( ) )

      return 0;

 

  // Declare a Source and assign the default TWAIN source to it

  DTwainSource Source = DTwainSource::SelectDefault( );

  if ( !Source.IsValid( ) )

     return 0;

 

  // Get all the capabilities

  DTwainLongArray Caps;

  Source.EnumSupportedCaps( Caps );

 

  // Output the numeric and string values of all the caps

  int nCount = Caps.size( );  // DTwainLongArray is a std::vector, so vector functions work here

  for ( int i = 0; i < nCount; ++i )

      cout << Caps[i] << " " << DTwainInterface::GetNameFromCap( Caps[i] ) << endl;

 

}  // Twain is shut down automatically on exit