VintaSoft Twain .NET SDK v10.2
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));
            }
        }
    }
                    
    



    FAQ: I cannot see devices in the TWAIN selection dialog of my application but I can see them in other applications. Why?

    Most probably you use your application in 64-bit system and your application is compiled as 64-bit application, in this case you need native 64-bit TWAIN driver for your device.

    You can compile your application in "Any CPU" mode and in this case:

    You can compile your application in "x86" mode and in this case:

    You can compile your application in "x64" mode and in this case:

    We recommend to use "x86" compilation mode because all scanners have 32-bit TWAIN drivers but only new and professional scanners have native 64-bit TWAIN drivers.