Opening and Handling Devices: 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.0.3
Released on:April 7, 2005
Author:IC Imaging Control Support Department
Requirements:IC Imaging Control >2.1
Camera, converter or grabber with WDM Stream Class drivers.

The dialog window of the sample application.

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).

Related Source Code Samples

Disclaimer
The source code that appears in the IC Imaging Control Source Code Library is indented for educational purposes only. The Imaging Source Europe GmbH, the manufacturer of IC Imaging Control, does not assume any kind of warranty expressed or implied, resulting from the use of the content of this page.

This site is part of The Imaging Source Network. Other sites include Company Portal, Image Processing, Astronomy Cameras, Astronomy Cameras Blog, Blog caméras d'astronomie, Astronomy Cameras Competition, TX Text Control, LiveDocx, phpLiveDocx and Forums.