32-bit and 64-bit Applications

Top  Previous  Next

DTWAIN comes with both 32-bit and 64-bit versions.  The 32-bit version of DTWAIN is implemented in DTWAIN32.DLL and DTWAIN32U.DLL. The 64-bit version of DTWAIN is implemented in DTWAIN64.DLL and DTWAIN64U.DLL (an explanation of the differences between the DLL's that end with the letter U is explained in the ANSI/MBCS and Unicode Applications section.  For now, assume that the U versions of the DTWAIN DLL are the same).

 

If you want to communicate with 64-bit TWAIN drivers, you must write a 64-bit application using DTWAIN64(U).DLL.  Similarly, to communicate with 32-bit TWAIN drivers, you must write 32-bit applications using DTWAIN32(U).DLL.  You cannot write a 64-bit application and communicate with 32-bit TWAIN drivers, and you cannot write 32-bit application and communicate with 64-bit TWAIN drivers.

 

Since 64-bit TWAIN drivers are much more rare than 32-bit drivers, most applications that communicate with TWAIN as of the writing of this manual are 32-bit based applications.  However, since 64-bit Windows operating systems are getting more prevalent, TWAIN drivers that will be 64-bit will increase in numbers, thereby forcing application writers to write 64-bit programs to communicate with such drivers and devices.

 

 

32-bit and 64-bit TWAIN Data Source Managers

 

In addition to DTWAIN32/64.DLL files, you must be aware of the different versions of the software that is used by DTWAIN to communicate messages between DTWAIN and the individual TWAIN devices.  This piece of software is in the form of a DLL, and it is called the TWAIN Data Source Manager, or DSM for short.  For 64-bit systems, the DSM is TWAINDSM.DLL, and for 32-bit systems, the DSM is TWAIN_32.DLL. The DSM is developed by the Twain Working Group (http://www.twain.org), the organization responsible for developing the TWAIN specification.  

 

For 32-bit operating systems, you will usually find TWAIN_32.DLL in the Windows System32 directory.  All 32-bit Windows operating systems (and 32-bit subsystem of 64-bit Windows operating system) includes this file as part of the operating system's base files, so there is no need for your application to install the Data Source Manager if you're targeting 32-bit applications.

 

For 64-bit Windows operating systems, there is no TWAIN Data Source Manager that is an integral component of the operating system.  Therefore included in the DTWAIN package is the 64-bit version of the DSM (TWAINDSM.DLL).  This version of the DSM is the Open Source DSM, again created by the Twain Working Group to support 64-bit TWAIN drivers and 64-bit TWAIN applications. Since TWAINDSM.DLL does not automatically come with the 64-bit operating system, you're responsible for making sure this file exists on the target computer when you install your 64-bit application (since the DSM is a dynamic link library, it should exist either in a directory specified in the PATH environment variable, or in your application's directory).

 

Please note:  When developing 64-bit TWAIN applications, the TWAINDSM.DLL must be located in the application's executable directory, or a directory that is accessible by the system's PATH environment variable.  Otherwise, your application will fail to initialize the 64-bit TWAIN system.

 

Note:

There is a 32-bit version of the Open Source TWAIN DSM.  If you are targeting 32-bit applications, and want to use the Open Source DSM, there is a special 32-bit version of TWAINDSM.DLL that you can install on your user's system, superseding TWAIN_32.DLL (you will also need to call the DTWAIN_SetTwainDSM function to use the open source DSM).

 

The major difference between TWAINDSM.DLL and TWAIN_32.DLL is that TWAINDSM.DLL (both 32 and 64-bit versions) has implemented the new TWAIN 2.0 specification for communicating and processing messages between the application (in this case, the DTWAIN library), and the DSM.   Regardless, you should not be concerned with these details of what each DSM supports, as DTWAIN is compatible with either TWAIN_32.DLL or TWAINDSM.DLL as the DSM.