VintaSoft Twain .NET SDK 12.1
In This Topic
    TWAIN devices
    In This Topic

    TWAIN device manager allows to show standard device selection dialog. Standard device selection dialog allows to view device list and select the default device. Standard device selection dialog can be shown using the DeviceManager.ShowDefaultDeviceSelectionDialog method.

    Here is an example that demonstrates how to show standard TWAIN device selection dialog:

    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Twain
    
    ''' <summary>
    ''' Shows standard TWAIN device selection dialog.
    ''' </summary>
    Private Sub ShowDeviceSelectionDialog()
        ' create device manager
        Using deviceManager As New Vintasoft.Twain.DeviceManager()
            ' open device manager
            deviceManager.Open()
    
            ' show standard TWAIN device selection dialog
            deviceManager.ShowDefaultDeviceSelectionDialog()
        End Using
    End Sub
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Twain
    
    /// <summary>
    /// Shows standard TWAIN device selection dialog.
    /// </summary>
    void ShowDeviceSelectionDialog()
    {
        // create device manager
        using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
        {
            // open device manager
            deviceManager.Open();
    
            // show standard TWAIN device selection dialog
            deviceManager.ShowDefaultDeviceSelectionDialog();
        }
    }
    


    Moreover TWAIN device manager allows to get device list programmatically. Device list can be get using the DeviceManager.Devices property. Information about the default device can be get using the DeviceManager.DefaultDevice property. Information about opened device can be get using the DeviceManager.OpenedDevice property.

    Here is an example that demonstrates how to get information about all devices installed in the system:
    ' The project, which uses this code, must have references to the following assemblies:
    ' - Vintasoft.Twain
    
    ''' <summary>
    ''' Gets information about all devices installed in the system.
    ''' </summary>
    Private Sub GetDevicesInfo()
        ' create device manager
        Using deviceManager As New Vintasoft.Twain.DeviceManager()
            ' open device manager
            deviceManager.Open()
    
            Dim devices As Vintasoft.Twain.DeviceCollection = deviceManager.Devices
            ' for each device
            For i As Integer = 0 To devices.Count - 1
                ' output the device name
                Console.WriteLine(String.Format("Device '{0}'", devices(i).Info.ProductName))
            Next
        End Using
    End Sub
    
    // The project, which uses this code, must have references to the following assemblies:
    // - Vintasoft.Twain
    
    /// <summary>
    /// Gets information about all devices installed in the system.
    /// </summary>
    void GetDevicesInfo()
    {
        // create device manager
        using (Vintasoft.Twain.DeviceManager deviceManager = new Vintasoft.Twain.DeviceManager())
        {
            // open device manager
            deviceManager.Open();
    
            Vintasoft.Twain.DeviceCollection devices = deviceManager.Devices;
            // for each device
            for (int i = 0; i < devices.Count; i++)
            {
                // output the device name
                System.Console.WriteLine(string.Format("Device '{0}'", devices[i].Info.ProductName));
            }
        }
    }