Home › Forums › TWAIN Classic › Windows: How do I get list of Data source and their identity
- This topic has 1 reply, 1 voice, and was last updated 9 years, 7 months ago by shlooks.
Viewing 2 posts - 1 through 2 (of 2 total)
- AuthorPosts
Hello,
Trying to eliminate the need for manual source selection in NAPS2(http://sourceforge.net/projects/naps2/). In order to achieve that, I thought it must be easy to somehow get list of all current DS and their identity, and then use it in the profile(Identity stored on XML).
Any idea how to do it ? (Any language)
Thanks
Found this in Python: (If anyone will ever need it)
from twain import *
from struct import *
SM = SourceManager(0L)
Identity = pack("156s", "")
firstResult = SM.DSM_Entry(DG_CONTROL, DAT_IDENTITY, MSG_GETFIRST, Identity)
print "Result code: ", firstResult
ProductName = Identity[122:]
iOffset = ProductName.find('')
if iOffset != -1:
ProductName = ProductName[:iOffset]
print "The data source name is: ", ProductName
while SM.DSM_Entry(DG_CONTROL, DAT_IDENTITY, MSG_GETNEXT, Identity) == 0:
ProductName = Identity[122:]
iOffset = ProductName.find('')
if iOffset != -1:
ProductName = ProductName[:iOffset]
print "The data source name is: ", ProductName
firstResult = SM.DSM_Entry(DG_CONTROL, DAT_IDENTITY, MSG_GETDEFAULT, Identity)
print "Result code: ", firstResult
ProductName = Identity[122:]
iOffset = ProductName.find('')
if iOffset != -1:
ProductName = ProductName[:iOffset]
print "The default data source name is: ", ProductName
print ProductName
- AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)