Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS TWAIN C DLL Help

L_TwainGetSources

Show in webframe

#include "lttwn.h"

L_LTTWN_API L_INT L_TwainGetSources (hSession, pfnCallBack, uStructSize, uFlags, pUserData)

HTWAINSESSION hSession;

/* handle to an existing TWAIN session */

LTWAINSOURCEINFOCALLBACK pfnCallBack;

/* optional callback function */

L_UINT uStructSize;

/* size in bytes, of the structure passed to the callback function */

L_UINT uFlags;

/* optional flags */

L_VOID * pUserData;

/* pointer to more parameters for the callback */

Gets the available information for the TWAIN sources installed on the system.

Parameter

Description

hSession

Handle to an existing TWAIN session. This handle is obtained by calling the L_TwainInitSession function.

pfnCallBack

Callback function for processing each enumerated TWAIN source. Use the function pointer as the value of this parameter.

 

L_TwainGetSources calls this callback function as it gets each TWAIN source. The callback function must adhere to the function prototype described in LTWAINSOURCEINFOCALLBACK Function.

uStructSize

Size in bytes, of the structure passed to the LTWAINSOURCEINFOCALLBACK callback function, for versioning. Use sizeof(LTWAINSOURCEINFO).

uFlags

Flags that indicate what sources to get. Possible values are:

 

Value

Meaning

 

LTWAIN_SOURCE_ENUMERATE_ALL

[0x0000] Enumerates all the available sources.

 

LTWAIN_SOURCE_ENUMERATE_DEFAULT

[0x0001] Gets only the default source (currently selected).

pUserData

Void pointer that you can use to pass one or more additional parameters that the callback function needs.

 

To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure.

 

If the additional parameters are not needed, you can pass NULL in this parameter.

Returns

SUCCESS

The function was successful.

! = SUCCESS

An error occurred. Refer to Return Codes.

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_TwainSelectSource.

Topics:

Managing the TWAIN Source

 

TWAIN Functionality: Property Functions.

Example

L_INT EXT_CALLBACK TwnSourcesCB(HTWAINSESSION     hSession,
                                pLTWAINSOURCEINFO pSource,
                                L_VOID         * pUserData)
{
   UNREFERENCED_PARAMETER(hSession);
   UNREFERENCED_PARAMETER(pUserData);

   L_TCHAR szBuffer[MAX_PATH];

   memset(szBuffer, 0, sizeof(szBuffer));
   wsprintf(szBuffer, TEXT("Source Name = %s\nProduct Family = %s\nManufacturer = %s\n"),
            pSource->pszTwnSourceName,
            pSource->pszTwnProductFamily,
            pSource->pszTwnManufacturer);

   MessageBox(NULL, szBuffer, TEXT("Source Info."), MB_OK);
   return TWAIN_SUCCESS;
}

 L_INT TwainGetSourcesExample(HTWAINSESSION hSession)
{
   L_INT nRet;

   nRet = L_TwainGetSources(hSession,
                            TwnSourcesCB,
                            sizeof(LTWAINSOURCEINFO),
                            LTWAIN_SOURCE_ENUMERATE_ALL,
                            NULL);
   if (nRet != SUCCESS)
   {
      MessageBox (NULL, TEXT("Error During Enumeration Procedure"), TEXT("ERROR"), MB_OK);
      return nRet;
   }
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.