Gets the container information for the specified capability.
#include "ltwrappr.h"
virtual L_INT LTwain::LockContainer(pCapability, ppContainer)
Pointer to a TW_CAPABILITY structure from which to get the container.
Pointer to be updated with a pointer to the container.
Value | Meaning |
---|---|
SUCCESS | The function was successful. |
< 1 | An error occurred. Refer to Return Codes. |
This function is used to lock the container present in the TW_CAPABILITY structure.
Once the user has the pointer to the container, the container may be changed. When the user has finished changing the container he or she must call LTwain::UnlockContainer to unlock the container. Note that this can also be accomplished using the C API GlobalLock and GlobalUnlock functions.
L_INT LTwain__LockContainerExample(LTwain *MyClass)
{
L_INT nRet;
TW_CAPABILITY twCap;
TW_ONEVALUE * ptwOneVal = NULL;
twCap.Cap = ICAP_XFERMECH;
twCap.ConType = TWON_DONTCARE16;
nRet = MyClass->GetCapability(&twCap, LTWAIN_CAPABILITY_GETCURRENT);
if (nRet != SUCCESS)
{
MessageBox (NULL, TEXT("Failed to get capability"), TEXT("ERROR"), MB_OK);
return nRet;
}
if (twCap.ConType == TWON_ONEVALUE)
{
nRet = MyClass->LockContainer(&twCap, (void **)&ptwOneVal);
if(nRet != SUCCESS)
return nRet;
if (ptwOneVal)
{
// Do processing
nRet = MyClass->UnlockContainer(&twCap);
if(nRet != SUCCESS)
return nRet;
}
}
return SUCCESS;
}