Home › Forums › TWAIN Classic › Problem using DG_CONTROL / DAT_CUSTOMDSDATA / MSG_SET
- This topic has 1 reply, 2 voices, and was last updated 8 years, 8 months ago by MarkM.
- AuthorPosts
Hello,
I’m developing an application that uses TWAIN (APP and DSM TWAIN 2.0 compliant) for scanning. This application allows users to set/get the current configuration of each device using DAT_CUSTOMDSDATA. When I get the CustomData and then set the same exported file, no error occurs and yet the values defined in the CustomData remain unchanged. I test the exported CustomData file in EZTWAIN tool and it works perfectly, so it must be an error in the set method. I’m using for testing the escanner Fujitsu fi-60f (DS TWAIN 1.0 compliant). Below I show the code i use for set.// pItem contain the customdata loaded directly from disk, pLength contain the length of pItem.
bool setCurrentCAP_CUSTOMDSDATA( uint8_t * pItem , uint32_t pLength )
{
bool result = false;
// Check if twain is in state 4.
if( TWAIN_state == TWAIN_STATE_4 )
{
// check that is supported CAP_CUSTOMDSDATA and CAP_ENABLEDSUIONL.
TW_CAPABILITY customDataCAP = queryCAP_CUSTOMDSDATA();
TW_CAPABILITY enableDsUiOnlyCAP = queryCAP_ENABLEDSUIONLY();
if( customDataCAP . hContainer && enableDsUiOnlyCAP . hContainer )
{
// Check if CAP_CUSTOMDSDATA and CAP_ENABLEDSUIONL values are true.
pTW_ONEVALUE customDataValuePtr = pTW_ONEVALUE( GlobalLock( customDataCAP . hContainer ) );
pTW_ONEVALUE enableDsUiOnlyValuePtr = pTW_ONEVALUE( GlobalLock( enableDsUiOnlyCAP . hContainer ) );
if( TW_BOOL( customDataValuePtr -> Item ) != FALSE && TW_BOOL( enableDsUiOnlyValuePtr -> Item ) != FALSE )
{
if( pItem && pLength > 0 )
{
pTW_CUSTOMDSDATA customData = getCurrentCAP_CUSTOMDSDATA();
if(customData && customData->hData && customData->InfoLength > 0)
{
customData->hData = GlobalAlloc( pLength );
memcpy( customData->hData , pItem,pLength );
customData->InfoLength = pLength;
// This function call ( *_DSM_EntryPtr )( AppIdPtr , SourceIdPtr , DG_CONTROL , DAT_CUSTOMDSDATA , MSG_SET, customData );
TW_UINT16 setCapabilityResult = getDSEntry( DG_CONTROL , DAT_CUSTOMDSDATA , MSG_SET , customData );
if( setCapabilityResult == TWRC_SUCCESS )
{
result = true;
}
}
}
}
GlobalUnlock( customDataCAP . hContainer );
GlobalUnlock( enableDsUiOnlyCAP . hContainer );
}
}
return result;
}Thanks
If you try the same thing with a Kodak Document Imaging scanner (running in simulation mode is fine for the test, an i5200 would serve well), you can see if the code works, and if not, I can probably offer some advice. Otherwise your best bet is to contact the vendor directly and see what help they can offer…
- AuthorPosts