DTWAIN_SysDestroy

Top  Previous  Next

The DTWAIN_SysDestroy function is called to release any resources used by the DTWAIN DLL and close the TWAIN session down safely.

 

DTWAIN_BOOL DTWAIN_SysDestroy( );

 

Parameters

None.

 

Return Values

The return value is TRUE if successful.  Otherwise FALSE is returned.

 

Comments

The DTWAIN_SysDestroy function must be called whenever the application no longer needs to call DTWAIN functions.   This function cleans up any resources that DTWAIN allocated to your application, as well as close any open Sources, destroys any DTWAIN_ARRAYs, and ends a started TWAIN session (if one has been started).  You must call DTWAIN_SysInitialize once again to reset the DTWAIN DLL structures if you have called DTWAIN_SysDestroy.

 

If a Source is currently acquiring an image (States 6 or 7), DTWAIN_SysDestroy will always return FALSE, and the TWAIN sub-system is not shutdown.   This ensures that the TWAIN sub-system is as stable as possible, since shutting down TWAIN when a Source is acquiring an image is not safe.

 

Basically, the application should not try to shutdown if a Source is currently acquiring an image.  DTWAIN cannot stop you from closing the application prematurely, but does warn you that a shutdown could not be done (the FALSE return value).  In the cases where the application needs to ensure that a Source is not acquiring data, the DTWAIN_IsAcquiring and DTWAIN_IsSourceAcquiring functions can be used to signal whenever it is safe to close the application down.  To ensure that DTWAIN_SysDestroy is called, the safest place to call DTWAIN_SysDestroy is on application shutdown (usually when the main window is destroyed).

 

Please note that if the process you're running detaches from the DTWAIN DLL, DTWAIN will automatically shut down by internally calling DTWAIN_SysDestroy.  For example, if your application has loaded DTWAIN DLL using the Windows LoadLibrary( ) function, if your application then calls FreeLibrary( ) without calling DTWAIN_SysDestroy, DTWAIN will internally call DTWAIN_SysDestroy.

 

 

TWAIN State Transitions

State 1

 

Prerequisite Calls

None.

 

Optional Prerequisite Calls

None.

 

See Also

DTWAIN_SysInitialize