Read the Serial Number of a Video Capture Device Sample code to read the serial number of a video capture device.
Language: | .NET C#/Visual Basic
Version: | 3.3
Author: | IC Imaging Control Support Department
Requirements: |
Software: | IC Imaging Control 3.3, Visual Studio™ 2010
Hardware: | Camera, converter or grabber with WDM Stream Class drivers.
Download C# sample | Read serial number - C#

Using only its serial number, it is possible to uniquely identify a video capture device. The Device object of IC Imaging Control exposes the method GetSerialNumber. This method is used to query the serial number of a video capture device.

First of all, the program lists the names of all available video capture devices connected to the computer in the listbox listBox1. The functionality for this is provided in the IC Imaging Control collection Devices. The listBox1.DataSource attribute is set to icImagingControl1.Devices to add the available video capture devices to the listbox.

    C#

    private void Form1_Load(object sender, System.EventArgs e)
    {
        listBox1.DataSource = icImagingControl1.Devices;
    }

When the user clicks one of the entries in the listbox listBox1, the program acquires the related video capture device, using listBox1.SelectedItem. The serial number of the acquired video capture device is read out using Device.GetSerialNumber. The queried serial number is displayed in the text box txtSerial:

    C#

    private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
    {
        Device selectedDevice = listBox1.SelectedItem as Device;

        if( selectedDevice != null )
        {
            string serial;
            if( selectedDevice.GetSerialNumber( out serial ) )
            {
                txtSerial.Text = serial;
            }
            else
            {
                txtSerial.Text = "No Serial Number";
            }
        }
    }

Important: It is not guaranteed that a video capture device (or a driver) allows its serial number to be read. Therefore, the return value of the method GetSerialNumber should always be checked (as shown above).