DTWAIN_SysInitializeLib

Top  Previous  Next

The DTWAIN_SysInitializeLib function initializes the DTWAIN static libraries for use with the application.  This function is only necessary if the DTWAIN resources are not located in the application that is being executed..

 

LONG DTWAIN_SysInitializeLib (

HINSTANCE

hInst );

 

Parameters

hInst

Instance handle of resource module.

 

Return Values

If the function succeeds, a non-zero value is returned.  If the function fails, zero (0) is returned.

 

Comments

 

If you are using the DTWAIN static libraries, and the DTWAIN resources will not be contained in the application, you must call DTWAIN_SysInitializeLib instead of DTWAIN_SysInitialize or DTWAIN_SysInitializeEx to initialize DTWAIN and to tell DTWAIN which module contains the DTWAIN resources.

 

For most applications that will use the DTWAIN static libraries, the resources (found in file TWCODES.RC) will be built within the final application, and all that is necessary is to call DTWAIN_SysInitialize or DTWAIN_SysInitializeEx.

 

However in rare cases, the programmer may have to explicitly let DTWAIN know which module contains the DTWAIN resources.  The DTWAIN_SysInitializeLib uses the hInst parameter as the instance handle of the module that contains the DTWAIN resources. Most notably, if you use the DTWAIN static libraries within another DLL, and an application that does not have the DTWAIN resources uses the DLL, you must call DTWAIN_SysInitializeLib in your DLL with the DLL instance handle, since by default, DTWAIN will attempt to use the instance handle of the application, not the DLL.

 

The instance handle can be retrieved with the following 'C' code:

 

#include <windows.h>

//...

char FileName[256];

GetModuleFileName( NULL, FileName, 255 );

DTWAIN_SysInitializeLib( GetModuleHandle( FileName ) );

//...

 

TWAIN State Transitions

State 1

 

Prerequisite Calls

None.

 

Optional Prerequisite Calls

None.

 

See Also

DTWAIN_SysDestroy, DTWAIN_IsTwainAvailable, DTWAIN_IsInitialized