dynarithmic / twain_library

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

How to get error details when an error occurs ? #31

Closed zongkaili closed 2 years ago

zongkaili commented 2 years ago

Hi, can i get the real error details when an error which like paper jam occurs ?
scanner : Canon DR-6030C TWAIN and HUAGOSCAN G400 TWAIN

LRESULT CALLBACK TwainCallbackProc(WPARAM wParam, LPARAM lParam, LONG_PTR UserData)

For example,I set the callback as above by calling DTWAIN_SetCallback , I want to get the lParam 'TWAIN_ERR_FEEDERJAMMED' when paper jam, but wParam is 1038, lParam is -1109 and -1023 which is not the real error code.

What can I do to get the actual error code ? please.

dynarithmic commented 2 years ago

Have you tried calling DTWAIN_SetDeviceNotifications? See also DTWAIN_IsDeviceEventSupported

Also, given the above, the DTWAIN_TN_DEVICEEVENT is the notification you should be handling. However, this will only be successful if:

a) the device supports device events, 
b) the device properly detects a paper jam and generates the correct error message
c) sends in the TWAIN message pump a MSG_DEVICEEVENT message that DTWAIN will process, and thus relay this in a 
    DTWAIN_TN_DEVICEEVENT notification.

Unfortunately I do not have the scanners you mentioned to verify if it can actually return the error codes that you mentioned. This is basically what you need to verify. Note that a lot of this depends on the driver behaving correctly, and DTWAIN has no control over drivers that may do things differently, incorrectly, or not all.

dynarithmic commented 2 years ago

Closing issue