TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

How can i communicate with twain from windows service ?

Forums › TWAIN Classic › How can i communicate with twain from windows service ?

  • This topic has 1 reply, 2 voices, and was last updated 6 years, 7 months ago by Catherine Sea.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • June 6, 2014 at 6:16 am #22954 Reply
    sandeep
    Participant
    • Topics - 1
    • Replies - 0
    • Total Posts - 1

    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.

    June 18, 2014 at 6:36 am #26156 Reply
    Catherine Sea
    Participant
    • Topics - 0
    • Replies - 59
    • Total Posts - 59

    Please make sure the current logon user of your service has proper permission to access C:Windowstwain_32 folder.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: How can i communicate with twain from windows service ?
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • To get the list of scanners from javascript client side (browser)
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.