VintaSoft Twain .NET SDK v10.3
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 shows how show standard TWAIN device selection dialog:

    ''' <summary>
    ''' Shows standard TWAIN device selection dialog.
    ''' </summary>
    Private Sub ShowDeviceSelectionDialog()
        ' create device manager
        Using deviceManager As New DeviceManager()
            ' open device manager
            deviceManager.Open()
    
            ' show standard TWAIN device selection dialog
            deviceManager.ShowDefaultDeviceSelectionDialog()
        End Using
    End Sub
                  
    
    /// <summary>
    /// Shows standard TWAIN device selection dialog.
    /// </summary>
    void ShowDeviceSelectionDialog()
    {
        // create device manager
        using (DeviceManager deviceManager = new 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 shows how get information about all devices installed in the system:
    ''' <summary>
    ''' Gets information about all devices installed in the system.
    ''' </summary>
    Private Sub GetDevicesInfo()
        ' create device manager
        Using deviceManager As New DeviceManager()
            ' open device manager
            deviceManager.Open()
    
            Dim devices As 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
                  
    
    /// <summary>
    /// Gets information about all devices installed in the system.
    /// </summary>
    void GetDevicesInfo()
    {
        // create device manager
        using (DeviceManager deviceManager = new DeviceManager())
        {
            // open device manager
            deviceManager.Open();
    
            DeviceCollection devices = deviceManager.Devices;
            // for each device
            for (int i = 0; i < devices.Count; i++)
            {
                // output the device name
                Console.WriteLine(string.Format("Device '{0}'", devices[i].Info.ProductName));
            }
        }
    }