本文介绍了WIA扫描Neatdesk的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用VB.Net扫描与Neatdesk扫描仪的双面接口。我目前只能扫描每个页面,并且无法将设备设置为双面打印。当我尝试设置双工参数时,我得到一个越界错误或访问被拒绝错误。这是我从其他来源找到并编辑的代码片段。
I am trying to scan duplex interfacing with Neatdesk scanner using VB.Net. I currently have the capability to scan each page front only, and have not been able to set the unit to duplex. When I try to set the duplex parameter, I either get a "out of bounds" error or "access denied" error. Here is my snippet of the code that I found and edited from other sources.
Dim DeviceManager1 = CreateObject("WIA.DeviceManager") 'wia device manager
For i = 1 To DeviceManager1.DeviceInfos.Count 'loop through all devices
If DeviceManager1.DeviceInfos(i).Type = 1 Then 'Select only scanners, not webcams etc...
Dim Scanner As WIA.Device = DeviceManager1.DeviceInfos(i).connect
Dim Img As WIA.ImageFile
Try
'MsgBox(Scanner.Properties("3088").Value.ToString)
With Scanner.Items(1)
.Properties("6146").Value = 4 '4 is Black-white,gray is 2, color 1 (Color Intent)
.Properties("3088").Value = &H4 'To print Duplex
End With
Finally
Img = Scanner.Items(1).Transfer("{B96B3CAE-0728-11D3-9D7B-0000F81EF32E}") 'Grab the image in jpeg format
Img.SaveFile(location & page & ".jpg")
End Try
End If
Next
如果我省略
If I omit the
.Properties("3088").Value = &H4
部分,我只能正面扫描我需要的所有文件。
感谢您的帮助。
portion, I am able to scan all the documents I need front face up only.
Thank you for the help.
推荐答案
'WIA_DPS_DOCUMENT_HANDLING_SELECT flags
const FEEDER = &H1
const FLATBED = &H2
const DUPLEX = &H4
const FRONT_FIRST = &H8
const BACK_FIRST = &H10
const FRONT_ONLY = &H20
const BACK_ONLY = &H40
const NEXT_PAGE = &H80
const PREFEED = &H100
const AUTO_ADVANCE = &H200
//this is from my GetPropertyName method
case PropertyId.DocumentHandlingSelect:
return "Document Handling Select";
internal static void SetDuplexMode(WIA.Device dev, bool useduplex)
{
try
{
//get device property for document handling select
WIA.Property prop = dev.Properties[GetPropertyName(PropertyId.DocumentHandlingSelect)];
if (prop != null)
{
//get current value
int mask = prop.get_Value();
if (useduplex) //enable duplexing
{
//mask "or equals" duplex (bit mask)
mask |= (int)document.handling.Select.DUPLEX;
}
else //disable duplexing
{
//mask "and equals" duplex (bit mask)
mask &= ~(int)document.handling.Select.DUPLEX;
}
//set value
prop.set_Value(mask);
}
}
catch (System.Runtime.InteropServices.COMException cex)
{
}
}
这篇关于WIA扫描Neatdesk的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!