TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Windows: How do I get list of Data source and their identity

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 6 years, 5 months ago by shlooks.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • August 30, 2014 at 4:19 pm #22969 Reply
    shlooks
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    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

    August 30, 2014 at 7:10 pm #26189 Reply
    shlooks
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    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
  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Windows: How do I get list of Data source and their identity
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • To get the list of scanners from javascript client side (browser)
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.