dynarithmic / twain_library

Dynarithmic TWAIN Library, Version 5.x
Apache License 2.0
60 stars 25 forks source link

How can i select a source without os dialog #23

Closed peng-kid closed 2 years ago

peng-kid commented 2 years ago

now i have two source: canon DR-M1060 and fi-7140 , i want to select canon DR-M1060 by my application , not by user select it in os dialog .

i think, i should do that steps:

  1. call DTWAIN_ArrayCreate(DTWAIN_ARRAYSOURCE, 0), then get an array;
  2. call DTWAIN_EnumSources , and get sources
  3. call DTWAIN_ArrayGetCount, check sources count

but, i get a empty array( size 0 ) after called DTWAIN_ArrayGetCount . Is there any error?

dynarithmic commented 2 years ago

1) I am assuming you are using C or C++.

2) Are you checking the return value when calling these functions?

3) Is this a 32-bit application or 64-bit application? If it's a 64-bit application and all of the Twain Sources are 32-bit, you will not get any available sources. The same thing vice-versa -- a 32-bit application cannot be used for Twain Sources that are 64-bit.

4) Did you try the DTWDEMO32U.EXE or DTWDEMO64U.exe program that is found in the binaries folder? That example program shows a custom select source dialog, where all of the names are retrieved using DTWAIN_EnumSources and populating a dialog box with those names.

5) As to the basic way to select a source, you would use DTWAIN_SelectSourceByName() to select a TWAIN source by using the product name. http://www.dynarithmic.com/onlinehelp5/dtwain/dtwain_selectsourcebyname.htm

peng-kid commented 2 years ago

thank you~ I tested the method you said 'DTWAIN_SelectSourceByName' and it met my needs ~