Home › Forums › TWAIN Classic › Using TWAIN from windows service application
- This topic has 4 replies, 2 voices, and was last updated 16 years, 2 months ago by gabe.
- AuthorPosts
Hi All,
I am a TWAIN newby, and i am trying to create the following :
I am building a Windows Service Application which should be able acces the scanner. But since i have no UI Interface i can’t figure how to instruct TWAIN to do this.
Is this possible ?
Yes this is possible. It’s tricky depending on your programming language to get the messagepump to work correctly but after the pump is running it isn’t too much work. I have a vb.net windows service to make scanners available over the network. it listens/watches a network share for message files and based on the files performs a scan.
In addition to the regular twain code you’ll have to work out some sort of dialog box management as a dialog box saying that the device is offline or that there has been a paperjam is a show stopper if the app is running as a service. From .net the dialog box manager was somewhat troublesome as it involved setting a cbthook and a shellhook. It didn’t initially seem that 2 different hooks would be required but some of the vendors don’t seem to… well some vendors are more creative than others.
The remaining piece is a config Ui, in my case I have a standard form that sets up a profile and saves the parameters, the config Ui communicates with the service via a ipcServerCahnnel. That part was simple enough.
The client side can be anything that is able to write the text files used for communication – in my case the client is a win32 app hosted by our main product.In general you’ll need to have a larger portion of the twain spec covered and implemented than if this were a desktop app as there won’t be much onscreen indication that something has gone wrong since the app will be running for all intents and purposes headless.
All in all it was a pain to write but the payoff is that our main product running in citrix/terminal server session is able to acquire images from the machine that started the session.
If you’re looking for help getting a project running, let me know what language you’re using and I try to help.
.
and read the spec end to end a least a couple times. I’m rather slow so it may not take you as long as it did me but I think by the 5th read the peices start to come together into a story (it’s a sad story with an unpleasant ending but at least it’s interesting)
.
Hi Gabe,
Thanks for your reply. I am planning to build exactly the same functionality as you already did, i wanted to see if i could share my scanner over the network using TWAIN.
I am using C# and the .NET framework 2.0, and currently am experimenting with this Twain.NET library :
I will continue reading the specs as you suggested.
Regards
Rob
my library is available at codeplex/opentwain. The sample projects I included are for winform and console project (the service project isn’t avaiable) same library can be used from within a service as it provides it’s own pump. A good deal of the dailog mangement is available there as well.
if you need help just ask.
.
- AuthorPosts