Enumerates all available system WIA devices connected to the user's machine.
Syntax
Visual Basic (Declaration) | |
---|
Public Sub EnumDevices() |
Visual Basic (Usage) | Copy Code |
---|
Dim instance As WiaSession
instance.EnumDevices()
|
C# | |
---|
public void EnumDevices() |
C++/CLI | |
---|
public:
void EnumDevices(); |
Example
Visual Basic | Copy Code |
---|
Public Sub EnumDevicesExample(ByVal parent As IWin32Window)
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
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 |
C# | Copy Code |
---|
public void EnumDevicesExample(IWin32Window parent) { 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 found device 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); } |
Remarks
Requirements
Target Platforms: Microsoft .NET Framework 3.0, Windows 2000, Windows XP, Windows Vista, Windows Server 2003 family, Windows Server 2008 family
See Also