VintaSoft Twain .NET SDK v10.2
In This Topic
    TWAIN device manager
    In This Topic

    TWAIN device manager is the library, which serves as a bridge between a TWAIN driver and user application (VintaSoft Twain .NET SDK).

    The following TWAIN device managers are present at current time:

    1. TWAIN_32.DLL - 32-bit TWAIN device manager compatible with TWAIN 1.x specification.
      This device manager allows to work only with 32-bit TWAIN 1.x and WIA drivers.
      Normally TWAIN_32.DLL is located in "C:\Windows\" directory and included in distributive package of all versions of Windows.

    2. TWAINDSM.DLL and TWAINDSM32.MSM - 32-bit TWAIN device manager compatible with TWAIN 2.x specification.
      This device manager allows to work only with 32-bit TWAIN 1.x and 2.x drivers.
      Files of this device manager are NOT included in distributive package of Windows. On 32-bit systems the TWAIN device manager files must be placed in "C:\Windows\System32\" directory. On 64-bit systems the TWAIN device manager files must be placed in "C:\Windows\SysWow64\" directory.
      Latest version of this device manager can be found here:
      http://www.twain.org or http://sourceforge.net/projects/twain-dsm/files/.

    3. TWAINDSM.DLL and TWAINDSM64.MSM - 64-bit TWAIN device manager compatible with TWAIN 2.x specification.
      This device manager allows to work only with 64-bit TWAIN 2.x drivers.
      Files of this device manager are NOT included in distributive package of Windows. On 64-bit systems the TWAIN device manager files must be placed in "C:\Windows\System32\" directory.
      Latest version of this device manager can be found here:
      http://www.twain.org or http://sourceforge.net/projects/twain-dsm/files/.

    Unfortunately, there is no TWAIN device manager that can work with 32-bit and 64-bit drivers at the same time and you must choose between 32-bit and 64-bit drivers. We recommend to use 32-bit drivers because most of scanners does not have 64-bit drivers.


    For working with TWAIN device manager it is necessary to create an instance of DeviceManager class. Type of TWAIN device manager can be set using the DeviceManager.IsTwain2Compatible property. The DeviceManager.IsTwainAvailable property allows to check if TWAIN device manager is present in the system. The DeviceManager.TwainDllPath property allows to define custom path to TWAIN device manager.

    Here is an example that shows how check if TWAIN device manager is installed in the system:
    ''' <summary>
    ''' Checks that TWAIN device manager is installed in the system.
    ''' </summary>
    Private Sub CheckTwain()
        Dim isTwainAvailable As Boolean = False
    
        Using deviceManager As New DeviceManager()
            deviceManager.IsTwain2Compatible = True
            If deviceManager.IsTwainAvailable Then
                Console.WriteLine("TWAIN device manager 2.x is available.")
                isTwainAvailable = True
            End If
    
            deviceManager.IsTwain2Compatible = False
            If deviceManager.IsTwainAvailable Then
                Console.WriteLine("TWAIN device manager 1.x is available.")
                isTwainAvailable = True
            End If
    
            If Not isTwainAvailable Then
                Console.WriteLine("TWAIN device manager is NOT available.")
            End If
        End Using
    End Sub
                  
    
    /// <summary>
    /// Checks that TWAIN device manager is installed in the system.
    /// </summary>
    void CheckTwain()
    {
        bool isTwainAvailable = false;
    
        using (DeviceManager deviceManager = new DeviceManager())
        {
            deviceManager.IsTwain2Compatible = true;
            if (deviceManager.IsTwainAvailable)
            {
                Console.WriteLine("TWAIN device manager 2.x is available.");
                isTwainAvailable = true;
            }
    
            deviceManager.IsTwain2Compatible = false;
            if (deviceManager.IsTwainAvailable)
            {
                Console.WriteLine("TWAIN device manager 1.x is available.");
                isTwainAvailable = true;
            }
    
            if (!isTwainAvailable)
                Console.WriteLine("TWAIN device manager is NOT available.");
        }
    }