Retrieving Current Unit of Measure

Top 

To retrieve the current unit of measure, the capability DTWAIN_CV_ICAPUNITS is used in conjunction with the DTWAIN_GetCapValues to determine the current unit of measure for the Source.  Below is a small function that determines the unit of measure for a Source.

 

/* Assume that DTWAIN_SysInitialize has been called,

as well as     */

 

LONG GetUnitOfMeasure(DTWAIN_SOURCE Source)

 

         DTWAIN_ARRAY Array;  /* Will have the unit when we're done */

         LONG UnitOfMeasure; /* Returned when we're done */

 

         DTWAIN_OpenSource(Source); /* Open Source */                

 

         /* Get the capability */

         DTWAIN_GetCapValues(Source,

                                         DTWAIN_CV_ICAPUNITS,

                                         DTWAIN_CAPGETCURRENT,

                                         &Array);

 

         if ( DTWAIN_ArrayGetCount(Array) <= 0 ) /* Error */

                         return -1L;

 

         /* Get the returned value from the array

         DTWAIN_ArrayGetAt(Array, 0, &UnitOfMeasure);

 

         /* Return what we have found */

         return UnitOfMeasure;