public void SelectDevice(
string deviceId
)
deviceId
String that contains the device ID. You can obtain this string by enumerating the available WIA devices on your machine.
Use this function when working with multiple WIA devices installed on a machine in order to select the WIA device without displaying the Select Device dialog. To do this, enumerate the WIA devices by calling the EnumDevices method. Then use it to keep a list of all received device IDs. Then call SelectDevice method using the device ID for the device to be selected.
using Leadtools;
using Leadtools.Codecs;
using Leadtools.Wia;
public void EnumDevicesExample(IntPtr parent)
{
if (!WiaSession.IsAvailable(WiaVersion.Version1))
{
Console.WriteLine("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)
{
Console.WriteLine("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);
}