WIA扫描Neatdesk [英] WIA Scanning for Neatdesk
本文介绍了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(3088)设置为值4.
您还需要选择FEEDER或FLATBED值。
因此,假设我想选择FEEDER(1)和DUPLEX(4)模式,你必须分配值5:
1 + 4 = 5
http://msdn.microsoft.com/en-us/library/windows/hardware/ff552792%28v=vs.85%29.aspx
I know this is an old thread, but if someone needs another solution, this might be it :
You cannot only set the WIA_DPS_DOCUMENT_HANDLING_SELECT (3088) to the value 4.
You need to select the FEEDER or FLATBED value as well.
So let's say i want to select the FEEDER (1) and the DUPLEX (4) mode, you would have to assign the value 5:
1 + 4 = 5
http://msdn.microsoft.com/en-us/library/windows/hardware/ff552792%28v=vs.85%29.aspx
我想你问题是颜色意图是项属性,但文档处理选择是设备属性。我没有在我面前使用我的WIA代码,但可能会有这些内容。
Scanner.Properties(3088)。值=& H4
而不是...
Scanner.Items(1).Properties ...
另外,文档处理select是一个标志属性,这里是来自wiadef.h的const值
I think your problem is that the color intent is a item property, but the document handling select is a device property. I don't have my WIA code in front of me but will probably be something along these lines
Scanner.Properties("3088").Value = &H4
instead of ...
Scanner.Items(1).Properties...
Also, the document handling select is a flag property, here are the const values from wiadef.h
'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
我查看了我的代码,这就是我为WIA启用双工的方法。我知道这是在C#中,但应该能够轻松地转换为VB。如果你需要它翻译,我可以花时间为你翻译。
I looked at my code and this is how I enable duplexing for WIA. I know this is in C# but should be able to translate to VB easily. If you need it translated I can take the time to translate it for you.
//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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文