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).
Here is a list of TWAIN device managers for Windows:
-
TWAIN_32.DLL file - 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 file is located in "C:\Windows\" directory and included in distributive package of all versions of Windows.
-
TWAINDSM.DLL and TWAINDSM32.MSM files - 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.
Default installation of Windows does not include TWAIN device manager and TWAIN device manager must be installed manually. 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: https://github.com/twain/twain-dsm/tree/master/Releases.
-
TWAINDSM.DLL and TWAINDSM64.MSM files - 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.
Default installation of Windows does not include TWAIN device manager and TWAIN device manager must be installed manually. 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: https://github.com/twain/twain-dsm/tree/master/Releases.
Here is a list of TWAIN device managers for Linux:
-
libtwaindsm.so file - 64-bit TWAIN device manager compatible with 2.x specification.
Default installation of Linux does not include TWAIN device manager and TWAIN device manager must be installed manually.
Latest version of TWAIN device manager can be found here: https://github.com/twain/twain-dsm/tree/master/Releases.
Installer installs libtwaindsm.so file in "/usr/local/lib/" directory.
If SDK is used in 32-bit application for Windows:
- the SDK can use 32-bit TWAIN device manager (TWAINDSM.DLL file), which is compatible with TWAIN 2.x specification.
- the SDK can use 32-bit TWAIN device manager (TWAIN_32.DLL file), which is compatible with TWAIN 1.x specification.
If SDK is used in 64-bit application for Windows:
- the SDK can use 64-bit TWAIN device manager (TWAINDSM.DLL file), which is compatible with TWAIN 2.x specification.
-
the SDK can use 32-bit TWAIN device manager (TWAINDSM.DLL file), which is compatible with TWAIN 2.x specification.
Important: Please read how to use 32-bit TWAIN driver in 64-bit application here.
Important: Please use 32-bit TWAIN driver in 64-bit application only if TWAIN scanner does not have 64-bit TWAIN driver.
If SDK is used in 64-bit application for Linux:
- the SDK can use 64-bit TWAIN device manager (libtwaindsm.so file), which is compatible with TWAIN 2.x specification.
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 demonstrates how to check if TWAIN device manager is installed in the system:
/// <summary>
/// Checks that TWAIN device manager is installed in the system.
/// </summary>
void CheckTwain()
{
bool isTwainAvailable = false;
// create the device manager
using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
{
// specify that TWAIN device manager 2.x must be used
deviceManager.IsTwain2Compatible = true;
// if TWAIN device manager 2.x is available
if (deviceManager.IsTwainAvailable)
{
System.Console.WriteLine("TWAIN device manager 2.x is available.");
isTwainAvailable = true;
}
// specify that TWAIN device manager 1.x must be used
deviceManager.IsTwain2Compatible = false;
// if TWAIN device manager 1.x is available
if (deviceManager.IsTwainAvailable)
{
System.Console.WriteLine("TWAIN device manager 1.x is available.");
isTwainAvailable = true;
}
// if TWAIN device manager is NOT available
if (!isTwainAvailable)
System.Console.WriteLine("TWAIN device manager is NOT available.");
}
}
''' <summary>
''' Checks that TWAIN device manager is installed in the system.
''' </summary>
Private Sub CheckTwain()
Dim isTwainAvailable As Boolean = False
' create the device manager
Using deviceManager As New Vintasoft.Twain.DeviceManager()
' specify that TWAIN device manager 2.x must be used
deviceManager.IsTwain2Compatible = True
' if TWAIN device manager 2.x is available
If deviceManager.IsTwainAvailable Then
System.Console.WriteLine("TWAIN device manager 2.x is available.")
isTwainAvailable = True
End If
' specify that TWAIN device manager 1.x must be used
deviceManager.IsTwain2Compatible = False
' if TWAIN device manager 1.x is available
If deviceManager.IsTwainAvailable Then
System.Console.WriteLine("TWAIN device manager 1.x is available.")
isTwainAvailable = True
End If
' if TWAIN device manager is NOT available
If Not isTwainAvailable Then
System.Console.WriteLine("TWAIN device manager is NOT available.")
End If
End Using
End Sub
Here is an example that demonstrates how to use 32-bit TWAIN and WIA devices in 32-bit application:
/// <summary>
/// Shows a list of 32-bit TWAIN and WIA drivers in 32-bit application.
/// </summary>
/// <remarks>
/// This code must be used in 32-bit application.
/// </remarks>
void Use32BitTwainAndWiaDriversIn32BitApplication()
{
// create the device manager
using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
{
// specify that TWAIN device manager 1.x must be used
deviceManager.IsTwain2Compatible = false;
// open the device manager
deviceManager.Open();
// show a dialog for selecting 32-bit TWAIN or WIA driver
deviceManager.ShowDefaultDeviceSelectionDialog();
}
}
''' <summary>
''' Shows a list of 32-bit TWAIN and WIA drivers in 32-bit application.
''' </summary>
''' <remarks>
''' This code must be used in 32-bit application.
''' </remarks>
Private Sub Use32BitTwainAndWiaDriversIn32BitApplication()
' create the device manager
Using deviceManager As New Vintasoft.Twain.DeviceManager()
' specify that TWAIN device manager 1.x must be used
deviceManager.IsTwain2Compatible = False
' open the device manager
deviceManager.Open()
' show a dialog for selecting 32-bit TWAIN or WIA driver
deviceManager.ShowDefaultDeviceSelectionDialog()
End Using
End Sub
Here is an example that demonstrates how to use 32-bit TWAIN devices in 64-bit application:
/// <summary>
/// Shows a list of 32-bit TWAIN drivers in 64-bit application.
/// </summary>
/// <remarks>
/// This code must be used in 64-bit application.
/// </remarks>
void Use32BitTwainDriversIn64BitApplication()
{
// create the device manager
using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
{
// specify that TWAIN device manager 2.x must be used
deviceManager.IsTwain2Compatible = true;
// specify that 64-bit TWAIN device manager 2.x must use 32-bit devices
deviceManager.Use32BitDevices();
// open the device manager
deviceManager.Open();
// show a dialog for selecting 32-bit TWAIN driver
deviceManager.ShowDefaultDeviceSelectionDialog();
}
}
''' <summary>
''' Shows a list of 32-bit TWAIN drivers in 64-bit application.
''' </summary>
''' <remarks>
''' This code must be used in 64-bit application.
''' </remarks>
Private Sub Use32BitTwainDriversIn64BitApplication()
' create the device manager
Using deviceManager As New Vintasoft.Twain.DeviceManager()
' specify that TWAIN device manager 2.x must be used
deviceManager.IsTwain2Compatible = True
' specify that 64-bit TWAIN device manager 2.x must use 32-bit devices
deviceManager.Use32BitDevices()
' open the device manager
deviceManager.Open()
' show a dialog for selecting 32-bit TWAIN driver
deviceManager.ShowDefaultDeviceSelectionDialog()
End Using
End Sub
Here is an example that demonstrates how to use 64-bit TWAIN devices in 64-bit application:
/// <summary>
/// Shows a list of 64-bit TWAIN drivers in 64-bit application.
/// </summary>
/// <remarks>
/// This code must be used in 64-bit application.
/// </remarks>
void Use64BitTwainDriversIn64BitApplication()
{
// create the device manager
using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
{
// specify that TWAIN device manager 2.x must be used
deviceManager.IsTwain2Compatible = true;
// open the device manager
deviceManager.Open();
// show a dialog for selecting 64-bit TWAIN driver
deviceManager.ShowDefaultDeviceSelectionDialog();
}
}
''' <summary>
''' Shows a list of 64-bit TWAIN drivers in 64-bit application.
''' </summary>
''' <remarks>
''' This code must be used in 64-bit application.
''' </remarks>
Private Sub Use64BitTwainDriversIn64BitApplication()
' create the device manager
Using deviceManager As New Vintasoft.Twain.DeviceManager()
' specify that TWAIN device manager 2.x must be used
deviceManager.IsTwain2Compatible = True
' open the device manager
deviceManager.Open()
' show a dialog for selecting 64-bit TWAIN driver
deviceManager.ShowDefaultDeviceSelectionDialog()
End Using
End Sub