You are on page 1of 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WIA;
using System.IO;

namespace scanner
{
public partial class Form1 : Form
{
// string deviceManager =new DeviceManager();
public Form1()
{
InitializeComponent();
}

private void butn_Click(object sender, EventArgs e)


{
for(int i=1;i<=new DeviceManager().DeviceInfos.Count;i++)
{
if (new DeviceManager().DeviceInfos[i].Type !=
WiaDeviceType.ScannerDeviceType)
{
textBox1.Text = (new
DeviceManager().DeviceInfos[i].Properties["Name"].get_Value()); //continue;
continue;
}

textBox1.Text = (new
DeviceManager().DeviceInfos[i].Properties["Name"].get_Value()); //continue;
}
}

private void button1_Click(object sender, EventArgs e)


{
DeviceInfo firstdevicescanner = null;
for (int i = 1; i <= new DeviceManager().DeviceInfos.Count; i++)
{
if (new DeviceManager().DeviceInfos[i].Type !=
WiaDeviceType.ScannerDeviceType)
{
// continue;
//}
firstdevicescanner = (new DeviceManager().DeviceInfos[i]);
//break;

}
}
if (firstdevicescanner == null)
{
MessageBox.Show("error");
}
else
{
Device d = firstdevicescanner.Connect();
Image f = ((Image)(d.Items[10]).Transfer());
pictureBox1.Image = f;
}

}
}
}

You might also like