Migrating Older Unicode Applications To 4.x

Top  Previous  Next

Prior to version 4.x of DTWAIN, the only DTWAIN DLL available was ANSI based.  This means that any Unicode-based applications using DTWAIN would use the ANSI version of DTWAIN, and call the string-related DTWAIN functions without having to specify character specific functions (the "A" and "W" functions discussed in ANSI and Unicode versions of DTWAIN functions).

 

For example, a Unicode application that used DTWAIN prior to version 4.x. would call DTWAIN_GetErrorString, and that function would automatically be ANSI, as that was the only version of DTWAIN that existed at that time.  However, it may become a problem with version 4.x of DTWAIN, as calling DTWAIN_GetErrorString in a Unicode build will, by default, generate a call to DTWAIN_GetErrorString that expects the application to provide a Unicode character-based buffer, and not an ANSI-based character buffer.

 

If you have developed a Unicode application that uses DTWAIN prior to version DTWAIN 4.x, and you want to continue using the ANSI DTWAIN DLL and you do not want to change your source code to call the ANSI specific versions of the DTWAIN functions, then you must rebuild your application defining the following compiler preprocessor constant:

 

DTWAIN_ANSIDLL

 

If this constant is defined, then all calls to the string-related DTWAIN functions will remain ANSI-based, and you can continue using DTWAIN32.DLL or DTWAIN64.DLL without any changes to your program source.

 

To define a compiler preprocessor symbol, most compilers have a -D or /D command-line parameter setting:

 

/D "DTWAIN_ANSIDLL"

 

If using the Microsoft Visual Studio Integrated Environment, the preprocessor symbols can be specified in the project options as below:

 

projopts2

 


 

The table below describes the various scenarios when building an application with DTWAIN using the various DTWAIN DLL types and application types.

 

Application Character Set Type

DTWAIN DLL Type

Preprocessor Constant to define

ANSI

ANSI

Not applicable

ANSI

Unicode

DTWAIN_UNICODEDLL

Unicode

Unicode

Not applicable

Unicode

ANSI

DTWAIN_ANSIDLL

 

The "Not applicable" means that no preprocessor symbol needs to be defined.

 

If you're building a Unicode application, and you want to use the ANSI DTWAIN DLL, you must define DTWAIN_ANSIDLL when compiling your application.  This forces DTWAIN to use ANSI string arguments for the DTWAIN functions instead of Unicode string arguments.  

 

If you're building an ANSI application, and you want to use the Unicode DTWAIN DLL, you must define DTWAIN_UNICODEDLL when compiling your application.  This forces DTWAIN to use Unicode string arguments for the DTWAIN functions instead of ANSI string arguments.  

Created with the Personal Edition of HelpNDoc: Create help files for the Qt Help Framework