DeviceManager manager = new DeviceManagerClass(); Device device = null; foreach (DeviceInfo info in manager.DeviceInfos) { if (info.Type != WiaDeviceType.ScannerDeviceType) continue; device = info.Connect(); break; } CommonDialogClass cdc = new WIA.CommonDialogClass(); Items items = cdc.ShowSelectItems(device, WiaImageIntent.UnspecifiedIntent, WiaImageBias.MaximizeQuality, false, true, false); MessageBox.Show(items.Count.ToString()); foreach (Item item in items) { CommonDialogClass cdcTemp = new WIA.CommonDialogClass(); ImageFile imageFile = cdcTemp.ShowTransfer(item, "{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}", true) as ImageFile; if (imageFile != null) { var buffer = imageFile.FileData.get_BinaryData() as byte[]; using (MemoryStream ms = new MemoryStream()) { ms.Write(buffer, 0, buffer.Length); pictureBox1.Image = Image.FromStream(ms); pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom; } } }
这样写可以得到第一张,后面的得不到,有没有做过的,看看