←Select platform

EnumDevices Method

Summary

Enumerates all available system WIA devices connected to the user's machine.

Syntax

C#
VB
C++
public void EnumDevices()
Public Sub EnumDevices()
public: 
void EnumDevices(); 

Remarks

This function will enumerate all available system WIA devices connected to the user's machine.

Information about each device found, like the device ID, device name and device description, can be retrieved by using the EnumDevicesEvent event. To do so, add this event when enumerating the available WIA devices. To cancel the enumeration process add this event and set the Cancel member of the WiaEnumDevicesEventArgs to true.

For more information, refer to Managing WIA Sources.

Example

C#
VB
Imports Leadtools 
      Imports Leadtools.Codecs 
      Imports Leadtools.Wia 
 
      <TestMethod()> _ 
#If Not LEADTOOLS_V19_OR_LATER Then 
      Public Sub EnumDevicesExample(ByVal parent As IWin32Window) 
#Else 
      Public Sub EnumDevicesExample(ByVal parent As IntPtr) 
#End If ' #If LEADTOOLS_V19_OR_LATER Then 
         If (Not WiaSession.IsAvailable(WiaVersion.Version1)) Then 
            MessageBox.Show("WIA version 1.0 not installed.") 
            Return 
         End If 
         Dim session As WiaSession = New WiaSession() 
         session.Startup(WiaVersion.Version1) 
 
         Dim res As DialogResult = session.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault) 
         If res <> DialogResult.OK Then 
            MessageBox.Show("Error selecting WIA device.") 
            session.Shutdown() 
            Return 
         End If 
 
         AddHandler session.EnumDevicesEvent, AddressOf session_EnumDevicesEvent 
 
         Console.WriteLine("Available WIA Devices:" & Constants.vbLf) 
         session.EnumDevices() 
 
         RemoveHandler session.EnumDevicesEvent, AddressOf session_EnumDevicesEvent 
 
         session.Shutdown() 
      End Sub 
 
      Private Sub session_EnumDevicesEvent(ByVal sender As Object, ByVal e As WiaEnumDevicesEventArgs) 
         Dim strMsg As String = String.Empty 
 
         ' print out some information about each device found into the console window. 
         strMsg = String.Format(Constants.vbTab & "Device Name: {0}" & Constants.vbLf + Constants.vbTab & "Device Id: {1}" & Constants.vbLf + Constants.vbTab & "Device Description: {2}" & Constants.vbLf + Constants.vbLf, e.DeviceName, _ 
               e.DeviceID, e.DeviceDesc) 
         Console.WriteLine(strMsg) 
      End Sub 
using Leadtools; 
      using Leadtools.Codecs; 
      using Leadtools.Wia; 
 
      [TestMethod] 
#if !LEADTOOLS_V19_OR_LATER 
      public void EnumDevicesExample(IWin32Window parent) 
#else 
      public void EnumDevicesExample(IntPtr parent) 
#endif // #if !LEADTOOLS_V19_OR_LATER 
      { 
         if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
         { 
            MessageBox.Show("WIA version 1.0 not installed."); 
            return; 
         } 
         WiaSession wiaSession = new WiaSession(); 
         wiaSession.Startup(WiaVersion.Version1); 
 
         DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault); 
         if (res != DialogResult.OK) 
         { 
            MessageBox.Show("Error selecting WIA device."); 
            wiaSession.Shutdown(); 
            return; 
         } 
 
         wiaSession.EnumDevicesEvent += new EventHandler<WiaEnumDevicesEventArgs>(wiaSession_EnumDevicesEvent); 
 
         Console.WriteLine("Available WIA Devices:\n"); 
         wiaSession.EnumDevices(); 
 
         wiaSession.EnumDevicesEvent -= new EventHandler<WiaEnumDevicesEventArgs>(wiaSession_EnumDevicesEvent); 
 
         wiaSession.Shutdown(); 
      } 
 
      void wiaSession_EnumDevicesEvent(object sender, WiaEnumDevicesEventArgs e) 
      { 
         string strMsg = string.Empty; 
 
         // print out some information about each device found into the console window. 
         strMsg = string.Format("\tDevice Name: {0}\n\tDevice Id: {1}\n\tDevice Description: {2}\n\n", e.DeviceName, e.DeviceID, e.DeviceDesc); 
         Console.WriteLine(strMsg); 
      } 

Requirements

Target Platforms

Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
Leadtools.Wia Assembly
Click or drag to resize