L_TwainInitSession2

#include "lttwn.h"

L_LTTWN_API L_INT L_TwainInitSession2(phSession, pAppData, uFlags)

pHTWAINSESSION phSession;

/* pointer to a TWAIN session handle */

pAPPLICATIONDATA pAppData;

/* pointer to the APPLICATIONDATA structure */

L_UINT uFlags;

/* optional flags */

Initializes the TWAIN session.

Parameter

Description

phSession

Pointer to a TWAIN session handle.  This handle is needed to acquire pages from the TWAIN source, and work with template files, containers, capabilities, and properties.

pAppData

Pointer to an APPLICATIONDATA structure. This structure will have the handle of the parent window, in addition to other data about the application.

uFlags

Flags that indicate the function behavior.  Possible values are:

 

Value

Meaning

 

LTWAIN_INIT_MULTI_THREADED

[0x0001] Initialize the Twain session with multi threaded option.

 

0

The function behavior will be like L_TwainInitSession

Returns

SUCCESS

The function was successful.

! = SUCCESS

An error occurred.  Refer to Return Codes.

Comments

L_TwainInitSession2 must be called before calling any other LEADTOOLS TWAIN toolkit functions.

When the handle to the TWAIN session is no longer needed, it should be freed by calling L_TwainEndSession. For every call to L_TwainInitSession2 there must be a call to L_TwainEndSession.

If you pass 0 to the uFlags parameter, then this function behavior will be like L_TwainInitSession, but if you pass LTWAIN_INIT_MULTI_THREADED to uFlags parameter, then the Twain session will be initialized with multi-threaded option.

Note: If this function returned ERROR_TWAIN_INVALID_DLL error then this is mostly because you have an old version of TWAINDSM.DLL in your system folder, you need to make sure you have at least version 2.0.9.0 of this DLL. You can download it from www.twain.org.

Required DLLs and Libraries

LTTWN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

L_TwainEndSession, L_TwainInitSession.

Topics:

Initializing a TWAIN Session

 

TWAIN Functionality: Session Functions.

Example

 L_INT TwainInitSession2Example(HWND hWnd,HBITMAPLIST hBitmap)
{
   L_INT nRet;
   L_BOOL bAvailable;
   HTWAINSESSION hSession = NULL;
   APPLICATIONDATA AppData;

   /* Check to see if TWAIN is installed */
   bAvailable = L_IsTwainAvailable(hWnd);
 
   if (bAvailable) 
   {
      AppData.hWnd = hWnd;
      lstrcpy (AppData.szManufacturerName, TEXT("LEAD Technologies, Inc."));
      lstrcpy (AppData.szAppProductFamily, TEXT("LEAD Test Applications"));
      lstrcpy (AppData.szVersionInfo, TEXT("Version 1.0"));
      lstrcpy (AppData.szAppName, TEXT("TWAIN Test Application"));
      nRet = L_TwainInitSession2(&hSession, &AppData, LTWAIN_INIT_MULTI_THREADED);
      if (nRet != SUCCESS)
         return nRet;

      nRet = L_TwainAcquireList(hSession, hBitmap, NULL, LTWAIN_SHOW_USER_INTERFACE);
      if(nRet != SUCCESS)
         return nRet;
      nRet = L_TwainEndSession(&hSession);
      if(nRet != SUCCESS)
         return nRet;
   }
   return SUCCESS;
}