public void Startup2(
The parent's window handle. This can be NULL.
Character string that contains the manufacturer's name (optional).
Character string that contains the application's product family (optional).
Character string that contains the version information (optional).
Character string that contains the application's name (optional).
Flag that determines the method's behavior.
Specifies which language to show in the UI.
Specifies which country to show in the UI.
A TWAIN session is a communication session between Leadtools.Twain and your TWAIN sources. The internal TWAIN session handle that is created provides access to this TWAIN session.
Either the Startup or the Startup2 method must be called before calling any LEADTOOLS TWAIN toolkit functions.
When the TWAIN session is no longer needed, end it by calling the Shutdown method. For every call to the Startup2 method there must be a call to the Shutdown method.
The behavior of the IsAvailable, Startup, and Startup2 functions depends on whether SetVersion has been called.
If SetVersion has not been called, the functions search for the 64-bit TWAINdsm driver first. If found, it is loaded and the TWAIN version will be "TWAIN_VERSION2".
If that fails or no 64-bit drivers are found, the TWAIN API internally calls the THUNK utility.
The following figure summarizes the default behavior.
Use the value of flags to specify the function's behavior, as follows:
Pass None to the flags parameter to initialize the TWAIN session without the multi-threaded option.
Pass InitializeMultithreaded to the flags parameter to initialize the TWAIN session with the multi-threaded option.
Pass UseThunkServer to the flags parameter to force the TWAIN session to use the THUNK utility. The LEADTOOLS THUNK utility was developed especially for those cases where 64-bit TWAIN drivers are not suitable/available for the application being developed. When the UseThunkServer flags is passed, the TWAIN API skips searching for 64-bit TWAIN drivers and only looks for the 32-bit TWAIN drivers. Pass this value only when using a TWAIN device that does not have a 64-bit driver and you are working on a 64-bit operating system. When using the THUNK server be sure to include in your distributables for your application all dependency files listed in the Using the LEADTOOLS THUNK Utility with TWAIN topic. This behavior is summarized in the following figure:
You can override the default behavior and explicitly set which version of TWAIN the selected device will use. To do so, call SetVersion and pass “Version1” to use version 1.9. The toolkit will only attempt to load the twain_32 DLL. Pass “Version2" to use version 2.x.
NOTE: Setting the version affects the behavior for the rest of the session. For more information, refer to Setting which TWAIN Specification Version to Use and Managing the TWAIN Source.
Call GetVersion to determine which TWAIN specification is currently being used by the LEADTOOLS TWAIN toolkit.
Note: If this function throws a TwainExceptionCode::InvalidDll exception, it is likely because the TWAINDSM.DLL's version in the system folder is old. Make sure to have at least version 18.104.22.168 of this DLL. You can download it from www.twain.org.
Note: If this function throws a TwainExceptionCode::NotInitialized exception while the UseThunkServer flag is used, then most likely it is because the THUNK server (ltthunkserver.exe) failed to start. In this case, make sure the ltthunkserver.exe is registered correctly and all dependencies listed in the Using LEADTOOLS THUNK Utility with TWAIN topic reside in the same folder where the ltthunkserver.exe is located. For more information, refer to Initializing a TWAIN Source, Freeing the TWAIN Session, and Using LEADTOOLS THUNK Utility with TWAIN.
Note: When using the thunk server, working on a 64-Bit operating system, and using a TWAIN device without a 64-Bit driver, it is preferred to pass
IntPtr.Zero to the
TWAIN Session Behavior
A TWAIN session is a communication session between LEADTOOLS Twain and your TWAIN sources. The internal TWAIN session handle provides access to this TWAIN session.
- For further details of the process flow summarizing the default behavior, refer to Startup2 Method: Default Behavior.
- For further details of the process flow summarizing the function's behavior when passing specific flags, refer to Startup2 Method: Using the Thunk Server.
public void Startup2Example(IntPtr parent)
TwainSession session = new TwainSession();
session.Startup2(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None, TwainLanguage.LanguageEnglish, TwainCountry.CountryUsa);
catch (Exception ex)
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms