Sets the options used for transferring data from the current TWAIN source.
#include "lttwn.h"
L_LTTWN_API L_INT L_TwainSetTransferOptions(hSession, pTransferOpts)
Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession or L_TwainInitSession2 function.
Pointer to the TRANSFEROPTIONS structure that contains the transfer options to set.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
To obtain the current transfer options, call L_TwainGetTransferOptions function.
This function should be called after calling the L_TwainStartCapsNeg function and before calling the L_TwainEndCapsNeg function.
L_INT TwainSetTransferOptionsExample(HTWAINSESSION hSession)
{
L_INT nRet = SUCCESS;
nRet = L_TwainStartCapsNeg (hSession);
if(nRet != SUCCESS)
return nRet;
L_UINT TransferModes = 0;
nRet = L_TwainGetSupportedTransferMode (hSession, &TransferModes);
if (nRet == SUCCESS)
{
if ((TransferModes & TWAIN_TRANSFER_FILE) == TWAIN_TRANSFER_FILE)
MessageBox(NULL, TEXT("File transfer is supported"), TEXT("Notice!"), MB_OK);
}
else
return nRet;
TRANSFEROPTIONS TransOpts;
memset(&TransOpts, 0, sizeof(TRANSFEROPTIONS));
nRet = L_TwainGetTransferOptions (hSession, &TransOpts, sizeof(TRANSFEROPTIONS));
if (nRet == SUCCESS)
{
if (TransOpts.TransferMode != TWAIN_TRANSFER_FILE)
{
TransOpts.TransferMode = TWAIN_TRANSFER_FILE;
_tcscpy_s(TransOpts.szFileName, MAX_PATH, MAKE_IMAGE_PATH(TEXT("test.bmp")));
TransOpts.uFileFormat = TWFF_BMP;
}
nRet = L_TwainSetTransferOptions(hSession, &TransOpts);
if(nRet != SUCCESS)
return nRet;
}
else
return nRet;
nRet = L_TwainEndCapsNeg(hSession);
if(nRet != SUCCESS)
return nRet;
return SUCCESS;
}