Starting a TWAIN Session

Top  Previous  Next

Before a TWAIN application can open a Source, it is necessary for the application to communicate with the TWAIN Data Source Manager (transition from TWAIN State 2 to State 3).  To do this, the DTWAIN_StartTwainSession function is called.  The TWAIN Data Source Manager (DSM) is implemented in either TWAIN_32.DLL or TWAINDSM.DLL, depending on whether your application will use the legacy Source Manager, or the version 2.x Source Manager, respectively (you can set the Source Manager to use by calling the DTWAIN_SetTwainDSM).

 

Normally, DTWAIN_StartTwainSession is automatically called by DTWAIN if a TWAIN session has not been started, and the application wants to select a TWAIN Source. DTWAIN is smart enough to start the TWAIN session if one has not been started.

 

However, the application can call DTWAIN_StartTwainSession explicitly.  The application will need to start a TWAIN session explicitly if it needs to do any of the following:

 

Monitor and control the acquisition process by setting the notification window and capturing DTWAIN notifications and messages.

Use a different TWAIN_32.DLL or TWAINDSM.DLL (the TWAIN Data Source Manager) other than the default.  This rarely, if ever, needs to be done by an application, but is provided as a diagnostic aid.

 

Locating and Loading the TWAIN DSM File