L_TwainAddCapabilityToFile

#include "lttwn.h"

L_LTTWN_API L_INT L_TwainAddCapabilityToFile (hSession, hFile, pCapability )

HTWAINSESSION hSession;

handle to an existing TWAIN session

HTWAINTEMPLATEFILE hFile;

handle to an existing template file

pTW_CAPABILITY pCapability ;

pointer to a structure

Adds a capability to a file.

Parameter

Description

hSession

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

hFile

Handle to an existing template file.

pCapability

Pointer to a structure that contains the capability to add.

Returns

SUCCESS

The function was successful.

! = SUCCESS

An error occurred. Refer to Return Codes.

Comments

In order to add a capability to a template file, the template file must first be opened for writing using the L_TwainOpenTemplateFile. Opening the file for writing will create a new empty file. The process of adding capabilities to the file will add them sequentially. When all capabilities have been added, save the file by calling L_TwainCloseTemplateFile. For more information on capabilities, refer to Getting and Setting Capabilities.

For more information on Template files, refer to Handling Template Files.

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_TwainOpenTemplateFile, L_TwainTemplateDlg, L_TwainGetCapabilityFromFile, L_TwainGetNumOfCapsInFile, L_TwainCloseTemplateFile, L_TwainInitSession, L_TwainEndSession.

Topics:

Handling Template Files

 

TWAIN Functionality: Capability Functions.

Example

L_INT CALLBACK SaveCapsCB (HTWAINSESSION  hSession, 
L_UINT         uCap, 
pTW_CAPABILITY pCapability, 
L_VOID      * pUserData) 
{ 
   UNREFERENCED_PARAMETER(uCap); 
   L_INT nRet; 
   HTWAINTEMPLATEFILE hFile = NULL; 
   if (!pUserData) 
      return SUCCESS; 
   hFile = (HTWAINTEMPLATEFILE)pUserData; 
   if (!pCapability) 
      return SUCCESS; 
   if (!pCapability->hContainer) 
      GlobalFreePtr (pCapability); 
   nRet = L_TwainAddCapabilityToFile (hSession, hFile, pCapability); 
   if (nRet != SUCCESS) 
      return nRet; 
   GlobalFree (pCapability->hContainer); 
   return SUCCESS; 
} 
L_INT TwainAddCapabilityToFileExample(HWND               hDlg, // Parent dialog handle 
HTWAINTEMPLATEFILE hFile, 
HTWAINSESSION g_hSession) 
{ 
   L_INT nRet; 
   OPENFILENAME ofn; 
   L_TCHAR szFilePath[MAX_PATH]; 
   memset (&ofn, 0, sizeof(OPENFILENAME)); 
   memset (szFilePath, 0, MAX_PATH); 
   ofn.lStructSize = sizeof(OPENFILENAME); 
   ofn.hwndOwner = hDlg; 
   ofn.lpstrFile = szFilePath; 
   ofn.nMaxFile = MAX_PATH; 
   ofn.lpstrFilter = TEXT("LEAD TWAIN TEMPLATE\0*.ltt\0All Files\0*.*\0\0"); 
   ofn.lpstrDefExt = TEXT("ltt"); 
   ofn.lpstrTitle = TEXT("Save Template File"); 
   ofn.Flags       = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; 
   if (GetSaveFileName (&ofn)) 
   { 
      nRet = L_TwainOpenTemplateFile (g_hSession, &hFile, szFilePath, LTWAIN_TEMPLATE_OPEN_WRITE); 
      if (nRet == SUCCESS) 
      { 
         nRet = L_TwainStartCapsNeg(g_hSession); 
         if(nRet != SUCCESS) 
            return nRet; 
         nRet = L_TwainEnumCapabilities (g_hSession, SaveCapsCB, LTWAIN_CAPABILITY_GETCURRENT, hFile); 
         if(nRet != SUCCESS) 
            return nRet; 
         nRet = L_TwainCloseTemplateFile (g_hSession, hFile); 
         if(nRet != SUCCESS) 
            return nRet; 
         nRet = L_TwainEndCapsNeg(g_hSession); 
         if(nRet != SUCCESS) 
            return nRet; 
      } 
      else 
         return nRet; 
   } 
   return SUCCESS; 
} 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS TWAIN C API Help