Initializes the TWAIN session.
public void Startup2(
Public Sub Startup2( _
ByVal owner As IntPtr, _
ByVal manufacturer As String, _
ByVal productFamily As String, _
ByVal version As String, _
ByVal application As String, _
ByVal flags As TwainStartupFlags, _
ByVal language As TwainLanguage, _
ByVal country As TwainCountry _
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.
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.
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 220.127.116.11 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.
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)
Public Sub Startup2Example(ByVal parent As IntPtr)
Dim session As TwainSession = New TwainSession()
session.Startup2(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None, TwainLanguage.LanguageEnglish, TwainCountry.CountryUsa)
Catch ex As Exception