In the past few days, I helped my colleagues solve the problem of connecting to the scanner. I checked WIA information and wrote a class, which is simple and shared to help you write scanning components.
This class requires the support of WIA components in windows. I put all the content in the additional code.
Using System;
Using System. Collections. Generic;
Using System. Text;
Using WIA;
Namespace Scaner
{
Public class Program
{
Public ImageFile Scan ()
{
DeviceManager manager = new DeviceManager ();
Device device = null;
Foreach (DeviceInfo info in manager. DeviceInfos)
{
If (info. Type! = WiaDeviceType. ScannerDeviceType) continue;
Device = info. Connect ();
Break;
}
Item item = device. Items [1];
CommonDialog cdc = new WIA. CommonDialog ();
ImageFile imageFile = cdc. ShowTransfer (item,
"{B96B3CAB-0728-11D3-9D7B-0000F81EF32E }",
True) as ImageFile;
Return imageFile;
}
}
}
Http://files.cnblogs.com/wengyuli/ScanApp.rar