The Document Imaging SDK provides function prototypes in generic, Windows code page, and Unicode versions. The prototypes can be compiled to produce either a Windows code page prototype or a Unicode prototype. All three prototypes are discussed and are illustrated by code samples for the OpenTiffFile function.
The following is an example of a generic prototype:
TIFFFILE CALLBACK OpenTiffFile(
LPTSTR lpszFileName,
int iMode
);
The header file provides the generic function name implemented as a macro.
#ifdef UNICODE
#define OpenTiffFile OpenTiffFileW
#else
#define OpenTiffFile OpenTiffFileA
#endif // !UNICODE
The preprocessor expands the macro into either the Windows code page or Unicode function name. The letter "A" (ANSI) or "W" (Unicode) are added at the end of the generic function name, as necessary. The header file then provides two specific prototypes, one for Windows code pages and one for Unicode, as shown in the following examples.
TIFFFILE CALLBACK OpenTiffFileW(
LPWSTR lpszFileName,
int iMode
);
TIFFFILE CALLBACK OpenTiffFileA(
LPSTR lpszFileName,
int iMode
);
The generic function prototype uses the data type LPTSTR for the text and file path parameter. However, the Windows code page prototype uses the type LPSTR, and the Unicode prototype uses LPWSTR. Note: Where LPCTSTR is used, the specific prototypes will also use the LPCSTR and the LPCWSTR data types as parameter.
For all functions with text arguments, applications should normally use the generic function prototypes. If an application defines "UNICODE" either before the #include statements for the header files or during compilation, the statements will be compiled into Unicode functions.
Note New Windows applications should use Unicode to avoid the inconsistencies of varied code pages and for ease of localization. They should be written with generic functions, and should define UNICODE to compile the functions into Unicode functions. In the few places where an application must work with 8-bit character data, it can make explicit use of the functions for Windows code pages.
When loading the dll file dynamically the dll itself only contains the “A” and “W” ended function names. The generic function prototypes are defined using the header file for static loading of the library.