Coding in C# and looking for the best way to persist the current used scanner for re-use. In WIA a guid is created and all you need to do is persist the value and then populate the value when needed. I am relatively new to TWAIN but did download some sample code and have an idea of what properties are available. I know when a scanner is detected the manufacturer, product family and product name are populated. I see an Id is populated but it does not appear to be a derived value. Is there a different strategy for TWAIN I am not seeing? Thanks in advance.
Your request is a little vague, but based on your WIA example I’m assuming that you’d like to establish the default TWAIN Driver, or at least have programmatic control of which one is opened.
If you control the scanner application the simplest way to do this is to specify the TW_IDENTITY.ProductName when you call DG_CONTROL / DAT_IDENTITY / MSG_OPENDS. You can get this value by enumerating through the available TWAIN drivers using DG_CONTROL / DAT_PARENT / MSG_GETFIRST and DG_CONTROL / DAT_PARENT / MSG_GETNEXT.
It’s also possible to set the default using DG_CONTROL / DAT_IDENTITY / MSG_SETDEFAULT, but this only works with the TWAINDSM.DLL module, and only makes sense if you can’t guarantee control of the applications that will use the scanner.