L_TwainGetCapabilityFromFile

Summary

Gets the capability, at the specified index, in the specified file.

Syntax

#include "lttwn.h"

L_LTTWN_API L_INT L_TwainGetCapabilityFromFile (hSession, hFile, ppCapability, uIndex)

Parameters

HTWAINSESSION hSession

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

HTWAINTEMPLATEFILE hFile

Handle to an existing template file.

pTW_CAPABILITY * ppCapability

Pointer to a pointer to a TW_CAPABILITY structure. This structure will be allocated internally.

L_UINT uIndex

Index of the capability to get from the file. This is a zero-based index.

Returns

Value Meaning
SUCCESS The function was successful.
! = SUCCESS An error occurred. Refer to Return Codes.

Comments

To get a capability stored in a file; the file must be opened for reading by calling L_TwainOpenTemplateFile function. The user must declare a variable of type pTW_CAPABILITY and pass the address of this to the function. This parameter will be updated with a pointer to the capability at the specified index.

Note: If the function is successful, the user must:

Required DLLs and Libraries

See Also

Functions

Topics

Example

L_INT  TwainGetCapabilityFromFileExample(HTWAINTEMPLATEFILE hFile, 
                                                         HWND               hDlg, // Parent dialog handle 
                                                         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.lpstrTitle = TEXT("Load Template File"); 
 
   if (GetOpenFileName (&ofn))  
   { 
      nRet = L_TwainOpenTemplateFile (g_hSession, &hFile, szFilePath, LTWAIN_TEMPLATE_OPEN_READ); 
 
      if (nRet == SUCCESS) 
      { 
         L_UINT uIndex, uCapCount = 0; 
         pTW_CAPABILITY ptwCapability = NULL; 
          
         nRet = L_TwainGetNumOfCapsInFile (g_hSession, hFile, &uCapCount); 
         if (nRet == SUCCESS) 
         { 
            for (uIndex = 0 ;uIndex < uCapCount ;uIndex ++) 
            { 
               nRet = L_TwainGetCapabilityFromFile (g_hSession, hFile, &ptwCapability, uIndex); 
               if (nRet == SUCCESS) 
               { 
                  nRet = L_TwainSetCapability (g_hSession, ptwCapability, LTWAIN_CAPABILITY_SET); 
                  if(nRet != SUCCESS) 
                     return nRet; 
               } 
               else 
               { 
                  return nRet; 
               } 
 
               if (ptwCapability) 
               { 
                  GlobalFree (ptwCapability->hContainer); 
                  GlobalUnlock(ptwCapability); 
                  GlobalFree (ptwCapability); 
               } 
            } 
         } 
         else 
            return nRet; 
 
         nRet = L_TwainCloseTemplateFile (g_hSession, hFile); 
         if(nRet != SUCCESS) 
            return nRet; 
      } 
      else 
         return nRet; 
   } 
   return SUCCESS;  
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS TWAIN C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.