Home › Forums › TWAIN Classic › Using TWAIN from windows service application › Reply To: Using TWAIN from windows service application
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.
.