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:
- 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.
- 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:
https://www.twain.org or https://sourceforge.net/projects/twain-dsm/files/.
- 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:
https://www.twain.org or https://sourceforge.net/projects/twain-dsm/files/.
If SDK is used in 32-bit application:
- the SDK can use 32-bit TWAIN device manager compatible with TWAIN 2.x specification (TWAINDSM.DLL)
- the SDK can use 32-bit TWAIN device manager compatible with TWAIN 1.x specification (TWAIN_32.DLL).
If SDK is used in 64-bit application:
- the SDK can use 64-bit TWAIN device manager compatible with TWAIN 2.x specification (TWAINDSM.DLL)
- the SDK can use 32-bit TWAIN device manager compatible with TWAIN 2.x specification (TWAINDSM.DLL).
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.
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:
' The project, which uses this code, must have references to the following assemblies:
' - Vintasoft.Twain
''' <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
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
Console.WriteLine("TWAIN device manager 1.x is available.")
isTwainAvailable = True
End If
' if TWAIN device manager is NOT available
If Not isTwainAvailable Then
Console.WriteLine("TWAIN device manager is NOT available.")
End If
End Using
End Sub
// The project, which uses this code, must have references to the following assemblies:
// - Vintasoft.Twain
/// <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.");
}
}
Here is an example that demonstrates how to use 32-bit TWAIN and WIA drivers in 32-bit application:
' The project, which uses this code, must have references to the following assemblies:
' - Vintasoft.Twain
''' <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
// The project, which uses this code, must have references to the following assemblies:
// - Vintasoft.Twain
/// <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();
}
}
Here is an example that demonstrates how to use 32-bit TWAIN drivers in 64-bit application:
' The project, which uses this code, must have references to the following assemblies:
' - Vintasoft.Twain
''' <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
// The project, which uses this code, must have references to the following assemblies:
// - Vintasoft.Twain
/// <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();
}
}
Here is an example that demonstrates how to use 64-bit TWAIN drivers in 64-bit application:
' The project, which uses this code, must have references to the following assemblies:
' - Vintasoft.Twain
''' <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
// The project, which uses this code, must have references to the following assemblies:
// - Vintasoft.Twain
/// <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();
}
}