ListDevices.vb

' ListDevices.vb - for LibTiePie 0.5+
'
' This example prints all the available devices to the screen.
'
' Find more information on http://www.tiepie.com/LibTiePie .

Imports System
Imports TiePie.LibTiePie

Module ListDevicesExample

    Sub Main()
        ' Print library information:
        PrintLibraryInfo()

        ' Update device list:
        DeviceList.Update()

        ' Get the number of connected devices:
        Dim connectedDevices As UInt32 = DeviceList.Count

        If connectedDevices <> 0 Then
            For i As UInt32 = 0 To connectedDevices - 1
                Try
                    Dim item As DeviceListItem = DeviceList.GetItemByIndex(i)

                    ' Print device info:
                    Console.WriteLine("  Name: " + item.Name)
                    Console.WriteLine("    Serial Number  : " + item.SerialNumber.ToString)
                    Console.WriteLine("    Available types: " + DeviceTypeToStr(item.Types))

                Catch e As System.Exception
                    Console.WriteLine("Exception: " + e.Message)
                    Environment.Exit(1)
                End Try
            Next
        Else
            Console.WriteLine("No devices found!")
            Environment.Exit(1)
        End If

        Environment.Exit(0)
    End Sub

End Module