Home › Forums › TWAIN Classic › How can i communicate with twain from windows service ?
- This topic has 1 reply, 2 voices, and was last updated 9 years, 10 months ago by Catherine Sea.
- AuthorPosts
Hi, Guys .. I need to find out if my HP duplex scanner is duplex or not.
I am using a windows service, that connects to the hp scanner via twain driver.
Now the problem i am facing is when i try getting the capabilities of the hp driver via twain , using a windows application , i get correct results , i.e “True” (my hp device supports duplex scanning).But when i try to get the same via a windows hosted windows service , i get “No Data Source”
when i selectSource
–> _session.SelectSource(_connectedDevice.DeviceID);When i went into the wrapper code of C# TWAIN ,
https://github.com/tmyroadctfig/twaindotnet (attached herein)
I found that the twain connects the data source ,(i.e the available twain scanner sources ) as below..Where in it requires the windows Message Hook ..
public class DataSource : IDisposable
{
Identity _applicationId;
IWindowsMessageHook _messageHook;public DataSource(Identity applicationId, Identity sourceId, IWindowsMessageHook messageHook)
{
….
_messageHook = messageHook;
}Now the Windows Message Hook ,
as show bellow requires a Window Handle,
and this is the reason why we are unable to get via either a Windows Service Hosted Scanner Service or Console Application.But we are able to get it via a Windows Application.public interface IWindowsMessageHook
{///
/// The handle to the window that is performing the scanning.
///IntPtr WindowHandle { get; }
}Does this mean i cannot get the capabilities of twain device driver without a windows handle, and hence i cannot connect and retrieve the driver capabilities of a scanner in twain driver via Windows service.
Could any one help me out please, i tried the approach with both console application in .net as well as windows service in wcf. All of them fail with “No data Source ” exception.
Only one that gets success is the “windows application in c# ” that i believe has a windows handle inbuild.any suggessions or leads of to achieve success via a windows service is very welcome.
Please make sure the current logon user of your service has proper permission to access C:Windowstwain_32 folder.
- AuthorPosts