dynarithmic / twain_library

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

scanner not found using DTWAIN_SelectSource #37

Closed j2t2 closed 1 year ago

j2t2 commented 1 year ago

One out of two scanners that I use for testing purposes (a Plustek OpticPro A360 Pro) is found as a source in the selection dialog called using DTWAIN_SelectSource(), the scanning function is working as expected. The other scanner however (a Plustek OpticSlim 1180) is not found.

There is no debug output, no error message, the result is the same as if the scanner was disconnected. I added a DTWAIN32.ini configuration and enabled DTWAIN logging to the debug console, but still got no error output. I also tried the QUERYSUPPORT=0 option.

According to the spec sheet, both of them are TWAIN compatible. Both of them correctly scan documents using an external scanning application, so the hardware and the Windows driver are working properly.

dynarithmic commented 1 year ago

1) The DTWAIN_SelectSource function will return an error code if the source cannot be opened. Once that happens then call DTWAIN_GetLastError. There is always a reason for the source not opening, and if DTWAIN_SelectSource or DTWAIN_OpenSource return an error, then that reason is known.

2) The INI functionality of DTWAIN is seldom used, thus it has not been tested thoroughly. I highly recommend you explicitly write the code to turn on logging (DTWAIN_SetTwainLog) and not use the INI to do so.

The INI functionality goes back to the commercial version of DTWAIN, but since DTWAIN went open-source, that functionality was not revisited. It would take extensive testing to incorporate the functionality within the open-source version of DTWAIN (which may happen in a future date).

dynarithmic commented 1 year ago

In addition, you should specify whether this is a 32-bit or 64-bit application. If it's 32-bit, then only 32-bit TWAIN drivers can be selected. Similarly, if it's a 64-bit application, only 64-bit drivers can be selected.

j2t2 commented 1 year ago

Thanks for your quick reply! It's a 64-bit application using Visual Studio 2022 on Windows 10. Unfortunately, I didn't get any error code. Before opening the selection dialog, there is no output. When selecting the scanner found, the integer error code is 0 (probably meaning no error). The other scanner doesn't show up in the selection dialog, so I can't select it to get an error message. I enabled the logging function using DTWAIN_SetTwainLog as you described, but the only line in the logfile is "** Log Started **".

dynarithmic commented 1 year ago

Is the application you are claiming here:

Both of them correctly scan documents using an external scanning application,

a 32-bit application or a 64-bit application? If it's a 32-bit application, then you should run the 32-bit version of DTWAIN, not 64-bit. As to the log file, that is very strange why you would only get a single line.

Did you try to run the DTWDEMO.EXE program? That has logging plus other scanning abilities in that one demo program. Run both the DTWDEMO32U.exe and DTWDEMO64U.exe programs.

dynarithmic commented 1 year ago

Closing this ticket, as the issue cannot be duplicated.