Startup Method

Summary
Initializes the TWAIN session.
Syntax
C#
VB
C++
public void Startup( 
   IntPtr owner, 
   string manufacturer, 
   string productFamily, 
   string version, 
   string application, 
   TwainStartupFlags flags 
) 
Public Sub Startup( _ 
   ByVal owner As IntPtr, _ 
   ByVal manufacturer As String, _ 
   ByVal productFamily As String, _ 
   ByVal version As String, _ 
   ByVal application As String, _ 
   ByVal flags As TwainStartupFlags _ 
)  
public: 
void Startup(  
   IntPtr owner, 
   String^ manufacturer, 
   String^ productFamily, 
   String^ version, 
   String^ application, 
   TwainStartupFlags flags 
)  

Parameters

owner
The parent window handle. This can be NULL.

manufacturer
Optional name of the application's manufacturer.

productFamily
Optional product family name.

version
Version information.

application
Optional application name.

flags
Flag that determines the Startup method's behavior

Remarks

Note that a TWAIN session is a communication session between LEADTOOLS TWAIN and your TWAIN sources. The internal TWAIN session handle that is created provides the user access to this TWAIN session. Startup or Startup2 must be called before calling any other methods that require a TWAIN session.

When the TWAIN session is no longer needed, end it by calling the Shutdown method. For each call to the Startup method there must be a call to the Shutdown method.

If you pass the UseThunkServer flag to the flags parameter, then the TWAIN session will be initialized using the THUNK server option. The only time to use the THUNK server is if you are using a TWAIN device that does not have a 64-Bit driver, and you are working on a 64-Bit operating system. In this case, this option will make it possible to detect and interact with your 32-Bit TWAIN driver/device from a 64-Bit process application.

Note: This method checks whether the currently selected TWAIN data source is TWAIN 2.x compliant. If the selected data source is TWAIN 2.x compliant, then the TWAIN 2.x data source manager (TWAINDSM.DLL) will be loaded from your system. The TWAIN version used will be TwainVersion2. If the selected data source is not TWAIN 2.x compliant, it will load the TWAIN 1.x data source manager (Twain_32.DLL) from your system. The TWAIN version used will be TwainVersion1. Checking will be done ONLY if the SetVersion method was NOT called by the user. To get the currently selected TWAIN version, call the GetVersion method.

Note: If this function throws a TwainExceptionCode::InvalidDll exception, most likely you have an old version of TWAINDSM.DLL in your system folder. Make sure you have at least version 2.0.9.0 of this DLL. Download it from www.twain.org.

Note: If this function throws a TwainExceptionCode::NotInitialized exception while the UseThunkServer flag is used, then most likely the THUNK server (ltthunkserver.exe) failed to start. In this case you need to make sure ltthunkserver.exe is registered correctly and that all dependencies listed in Using the LEADTOOLS THUNK Utility with TWAIN topic reside in the same folder where ltthunkserver.exe is located.

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 owner parameter.

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 more information, refer to Initializing a TWAIN Source, Freeing the TWAIN Session, and Using the LEADTOOLS THUNK Utility with TWAIN.

Example
C#
VB
using Leadtools; 
using Leadtools.Twain; 
 
public void StartupExample(IntPtr parent) 
{ 
   TwainSession session = new TwainSession(); 
   session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); 
 
   try 
   { 
      session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); 
   } 
   catch (Exception ex) 
   { 
      MessageBox.Show(ex.Message); 
   } 
 
   session.Shutdown(); 
} 
Imports Leadtools 
Imports Leadtools.Twain 
 
Public Sub StartupExample(ByVal parent As IntPtr) 
   Dim session As TwainSession = New TwainSession() 
   session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None) 
 
   Try 
      session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None) 
   Catch ex As Exception 
      MessageBox.Show(ex.Message) 
   End Try 
 
   session.Shutdown() 
End Sub 
Requirements

Target Platforms

Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Twain Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.