Loading/Unloading the DTWAIN DLL
If you're using a language where the DTWAIN DLL has to be explicitly loaded and unloaded using your language's commands/functions, it is desirable to have the load and unload sequence done once and only once during the running of your application. Otherwise repeatedly loading and unloading the DTWAIN DLL during the running of your application incurs a runtime penalty in that the DLL has to reinitialize itself each time, load itself back into memory, etc.
For example, if using C/C++, and your application decides to load the DTWAIN32.DLL dynamically at runtime using the Win32 API functions LoadLibrary and FreeLibrary:
HMODULE hMod = LoadLibrary( "DTWAIN32.DLL" ) //... FreeLibrary( hMod ); //...
This sequence of commands should be done once per application run. The best place to do the load would be at or near application startup, and the unload should be at or near application termination.
Other languages have similar, if not identical constructs for loading and unloading DLL's -- the same advice applies to those languages. Always strive to minimize the number of times your application explicitly loads and unloads the DTWAIN DLL files, and keep the DLL loading at/near application start and the unload of the DLL near or at application termination. |