WIA Twain support C#

北城余情 提交于 2019-12-06 04:10:26

问题


How can I use WIA and Twain in C#? The TWIAIN/C# example found at http://www.codeproject.com/KB/dotnet/twaindotnet.aspx Throws an exception at line 59 on TwainLib.cs "an attempt was made to load a program with an incorrect format." on Vista 64.

I would use WIA but it does not have support for all of the devices I want to use.

Is there a simple way to enable TWAIN support in WIA in C#? I know it can be done but I cannot find any documentation on the subject. I am not looking for a commercial product. I can figure out how to use WIA just fine - but its the fact that I cant enable TWIAN support that is annoying.

Examples in C++/CLI or VB.net are also welcome.

Thanks.

EDIT

Thanks, cristianlibardo. You helped me out a lot and I might just continue to use TWIAN for now. But I am still wanting to use WIA; so I will not accept your answer yet. Here is some more info for people just seeing this post. All are in response to this answer:

Yup, that did it for the TWIAN support; thanks! I still want to use WIA though; but now I have something to work with. However, when I select my USB camera as the source and hit acquire, the app hangs. My camera works on other, commercial, TWIAN applications.

By commenting out the lines 100 though 104 (code that checks to see if "DScap( appid, srcds, TwDG.Control, TwDAT.Capability, TwMSG.Set, cap );" returns TwRC.Success my Camera now works. I have no idea what this code does; as documentation is next-to-nothing on this subject.

OK; its a const called "CAP_XFERCOUNT" that has something to do with scanning multiple images per session. Makes seance that a camera would not support it.


回答1:


Probably a long shot but have your tried building with x86 as platform target or changing thread apartment state?



来源:https://stackoverflow.com/questions/274127/wia-twain-support-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!