I'm trying to identify the scanners attached to the computer. One of the possible solutions is to use WIA (Windows Image Acquisition Automation Library).
These were my actions so far:
- Download wiaaut.dll
- Copy it to system32
- Register it with "regsvr32 wiaaut.dll" (successfully)
- Add reference to my project in Visual Studio.NET
- Check that the Windows Image Acquisition (WIA) service is running
Next, I add and debug the following code:
WIA.DeviceManager manager = new WIA.DeviceManagerClass();
string deviceName = "";
foreach (WIA.DeviceInfo info in manager.DeviceInfos)
{
if (info.Type == WIA.WiaDeviceType.ScannerDeviceType)
{
foreach (WIA.Property p in info.Properties)
{
if (p.Name == "Name")
{
deviceName = ((WIA.IProperty)p).get_Value().ToString();
Console.WriteLine(deviceName);
}
}
}
}
However, the manager.DeviceInfos is always empty. I have 2 scanners attached, one of them shows in Control Panel->Scanners and Cameras, one doesn't, and both show under "Imaging Devices" in Device manager.
Any suggestion on why none are appearing in WIA.DeviceManager.DeviceInfos?
Running on Windows XP Service Pack 2