L_TwainInitSession2

#include "lttw2.h"

L_INT EXT_FUNCTION 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.

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

void TestTWAIN2(HWND hWnd, HBITMAPLIST hBitmap)
{
   L_BOOL bAvailable;
   L_INT nRet;
   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;

      L_TwainAcquireList(hSession, hBitmap, NULL, LTWAIN_SHOW_USER_INTERFACE);
      L_TwainEndSession(&hSession);
   }
}