Controlling the Scanning Capabilities and Other Options

 

There are a lot of capabilities for scanners. Not all scanners support all of the capabilities. The CAP_SUPPORTEDCAPS capability retrieves the list of supported capabilities. You can get/set/reset capabilities with the GetCapabilityOneValue, GetCapabilityArray, GetCapabilityEnum, GetCapabilityRange, SetCapabilityOneNumValue, SetCapabilityOneStrValue, SetCapabilityNumRange, SetCapabilityNumArray, SetCapabilityNumEnum functions/methods of the BiTWAIN DLL/OCX.

 

If the capability is supported by the scanner the IsCapabilitySupported function/method returns TRUE.

 

[C++]

 

#include “BiTwain.h”

 

/* Get current value of horizontal resolution */

DWORD dwNeeded, dwReturned;

LPSTR szValue = NULL;

 

 

int err = GetCapabilityOneValue(ICAP_XRESOLUTION,

MSG_GETCURRENT,

NULL, 0, &dwNeeded, &dwReturned);

 

if (dwNeeded > 0)

{

            szValue = (LPSTR)calloc(dwNeeded, sizeof(char));

            if (szValue)

            {

                        DWORD dwBuf = dwNeeded;

                        err = GetCapabilityOneValue(ICAP_XRESOLUTION,

MSG_GETCURRENT, szValue, dwBuf, &dwNeeded,

&dwReturned);

 

                        if (err == TW_OK && dwBuf == dwReturned)

                        {

                                    // Success

                                    int xRes = atoi(szValue);

                        }

                        free(szValue);

            }

}

 

[VB]

 

Dim err As Long

Dim szValue As String

Dim xRes As Long

 

szValue = BiTwain.GetCapabilityOneValue(ICAP_ XRESOLUTION,

MSG_GETCURRENT)

 

If BiTwain.ErrorCode = TW_OK Then

   xRes = CLng(szValue)

End If

 

[C#]

 

string szValue;

int xRes;

 

szValue = BiTwain.GetCapabilityOneValue(

(int)BITWAINLib .enumCapabilities.ICAP_XRESOLUTION, (int)BITWAINLib.enumCapabilityOperations.MSG_GETCURRENT);

 

if (BiTwain.ErrorCode ==

(int)BITWAINLib.enumErrorCodes.TW_OK)

{

            xRes = Convert.ToInt32(szValue);

}