Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
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 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: |
|
|
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); GlobalFreePtr (pCapability); 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.lpstrTitle = TEXT("Save Template File"); if (GetSaveFileName (&ofn)) { nRet = L_TwainOpenTemplateFile (g_hSession, &hFile, szFilePath, LTWAIN_TEMPLATE_OPEN_WRITE); if (nRet == SUCCESS) { 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; } else return nRet; } return SUCCESS; }