Development Issues

Top  Previous  Next

Since DTWAIN operates as a generic Windows 32 or 64 bit Dynamic Link Library (DLL), any Windows environment that allows calls to external DLL's can use DTWAIN.  This includes Visual Basic, Delphi, C#, Python, Perl, Java (using JNI), and many others. 

 


Before starting, you must make sure that the DTWAIN DLL file is available either in your application's executable directory, or one of the directories specified on your system PATH.  The reason for this is that your program will attempt to issue calls to the DTWAIN DLL, and if the DLL can't be found by the operating system, the call will fail and the program more than likely will terminate with an error.

 

The DTWAIN DLL file will be either one of the following, depending on your development plans:
 
DTWAIN32.DLL          (For 32-bit non-Unicode (ANSI) applications)
DTWAIN32U.DLL        (For 32-bit Unicode applications)

DTWAIN64.DLL          (For 64-bit non-Unicode applications)

DTWAIN64U.DLL        (For 64-bit Unicode applications)

 

Please note that 64-bit applications can only communicate with 64-bit TWAIN drivers and devices.  Similarly, 32-bit applications can only communicate with 32-bit TWAIN drivers and devices.


In addition to the above DLL's, there are text-based resource files that must reside in the same place as the DTWAIN DLLs.  The names of the resource files are as follows:


twaininfo.txt

twainresourcestrings_english.txt


The files above are required, since they contain all the information concerning the naming of the TWAIN capabilities, triplet information, etc.  You do not need to know what these various aspects of TWAIN are -- just make sure these files reside in the same directory as the dtwain*.dll when your application is executed.  An error is displayed if DTWAIN cannot find these files or the files are corrupted and/or cannot be opened.


 

The topics below contain extra information on programming languages that DTWAIN has been tested with:

C and C++ Development Issues

Visual Basic Development

Embardaero Delphi Development

C# Development

Perl Development

XBase++ Development

Macro Scheduler Development

 

For other languages not listed above:

Development in Other Languages

 

For development issues dealing with bitmap and floating point data, and loading/unloading the DTWAIN DLL during runtime:

Bitmap Data and TWAIN

Floating Point Issues and DTWAIN

Loading and Unloading the DTWAIN Dynamic Link Library at runtime

 

Consult the user's manual of your programming environment for information on how to make calls to external DLL's.  If you need to set up an interface to the DTWAIN functions and are not sure how to set up the parameters for the DTWAIN functions, the best approach is to see how your environment defines the parameters when calling a Windows API function such as CreateWindow, BitBlt, GetWindowText, etc.  Almost all programming documentation for various languages have code samples of calling a Windows API function, so you can use this as a template when interfacing to DTWAIN.

 

Please note that the DTWAIN documentation assumes you know the computer language you're using fully enough to make correct calls to external DLL functions.

For example, if a DTWAIN function requires a string buffer that will be filled in by the DTWAIN function on return, it is assumed that your program written in the computer language you're using has already allocated space for the character buffer before calling the DTWAIN function,  or if a function requires a LONG value, you're sending a 32-bit integer and not a string, etc.

 

Most of the DTWAIN function parameter types match as closely as possible to the usual parameter types that you will see associated with Windows API functions. For example, LPCTSTR, LPVOID, LONG, BOOL, etc. that DTWAIN uses are exactly the same types as used with the Windows API functions.

 

Here is a small table of how to interpret the various DTWAIN types using the standard 'C' language types:

 

DTWAIN Type

Definition

'C' / Windows equivalent

DTWAIN_SOURCE        

32-bit integer

LONG

LPDTWAIN_SOURCE

32-bit void pointer

void FAR * (or LPVOID)

DTWAIN_ARRAY

32-bit integer

LONG

LPDTWAIN_ARRAY

32-bit void pointer

void FAR * (or LPVOID)

DTWAIN_IDENTITY

32-bit integer

LONG

DTWAIN_STRING

array of 256 chars

LPTSTR

DTWAIN_LONGSTRING

array of 1,024 chars

LPTSTR

DTWAIN_FLOAT

8 byte IEEE floating point

double

DTWAIN_LONG

32-bit integer

LONG

DTWAIN_BOOL

32-bit integer

LONG

DTWAIN_LONG64

64-bit integer

LONGLONG (or __int64)

 

 

For 64-bit applications, some of the above definitions will be 64-bit integers and pointers.  Here is a table of the differences between the 32-bit definitions and 64-bit definitions:

 

DTWAIN Type

Definition

'C' / Windows equivalent

DTWAIN_SOURCE        

64-bit integer

LONGLONG (or __int64)

LPDTWAIN_SOURCE

64-bit void pointer

void FAR * (or LPVOID)

DTWAIN_ARRAY

64-bit integer

LONGLONG (or __int64)

LPDTWAIN_ARRAY

64-bit void pointer

void FAR * (or LPVOID)

DTWAIN_IDENTITY

64-bit integer

LONGLONG (or __int64)

 

If your language environment does not support floating point values, please read the section on Floating Point Issues and how to circumvent the limitation on floating point.

 

The files above are required, since they contain all the information concerning the naming of the TWAIN capabilities, triplet information, etc. You do not need to know what these various aspects of TWAIN are -- just make sure these files reside in the same directory as the dtwain*.dll when your application is executed.

If these files are not found, you will receive the following error when running your application;


The files above are required, since they contain all the information concerning the naming of the TWAIN capabilities, triplet information, etc. You do not need to know what these various aspects of TWAIN are -- just make sure these files reside in the same directory as the dtwain*.dll when your application is executed.

If these files are not found, you will receive the following error when running your application;


The files above are required, since they contain all the information concerning the naming of the TWAIN capabilities, triplet information, etc. You do not need to know what these various aspects of TWAIN are -- just make sure these files reside in the same directory as the dtwain*.dll when your application is executed.

If these files are not found, you will receive the following error when running your application;


The files above are required, since they contain all the information concerning the naming of the TWAIN capabilities, triplet information, etc. You do not need to know what these various aspects of TWAIN are -- just make sure these files reside in the same directory as the dtwain*.dll when your application is executed.

If these files are not found, you will receive the following error when running your application;