Opening and Handling Devices: Read Serial Number

This programming example illustrates how to read a device's serial number, using IC Imaging Control.
Language:Visual Basic 6
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.

As every device has its own serial number, it is a good parameter by which to identify a device. The code below illustrates how to read a device's serial number.

The finished application looks as is illustrated by the following screenshot:

The dialog window of the sample application.

First of all, the sample application lists the names of all devices available on the system in the ListBox lstDevices (see right hand image below). The functionality in order to create the list is provided by the collection Devices. .Devices.Count indicates the number of devices found, while Devices(i) returns information about the i-th device (as for instance the name):

Private Sub Form_Load()
    For i = 1 To ICImagingControl1.Devices.Count
        lstDevices.AddItem ICImagingControl1.Devices(i).Name
    Next i
End Sub

When one of the listed names is clicked, the sample application acquires the device (selectedDevice). Then, using GetSerialNumber it reads the serial number and assigns it to the text field txtSerial.

Private Sub lstDevices_Click()

    Dim selectedDevice As Device
    Set selectedDevice = ICImagingControl1.Devices(lstDevices.ListIndex + 1)

    Dim serial As String
    If selectedDevice.GetSerialNumber(serial) Then
        txtSerial.Text = serial
    Else
        txtSerial.Text = "No serial number"
    End If

End Sub

It is important to note that not all devices allow their serial number to be read. It is therefore essential that the return value of GetSerialNumber be checked, as is illustrated in the above source code.

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.