0

Im trying to Scan an image from a scanner connected to my device, I tried using WIA, but not all scanners support it, I found a project made on Windows forms and WPF in https://github.com/tmyroadctfig/twaindotnet

public class WpfWindowMessageHook : IWindowsMessageHook
{
    HwndSource _source;
    WindowInteropHelper _interopHelper;
    bool _usingFilter;

    public WpfWindowMessageHook(Window window)
    {
        _source = (HwndSource)PresentationSource.FromDependencyObject(window);
        _interopHelper = new WindowInteropHelper(window);            
    }

    public IntPtr FilterMessage(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {
        if (FilterMessageCallback != null)
        {
            return FilterMessageCallback(hwnd, msg, wParam, lParam, ref handled);
        }

        return IntPtr.Zero;
    }

    public bool UseFilter
    {
        get
        {
            return _usingFilter;
        }
        set 
        {
            if (!_usingFilter && value == true)
            {
                _source.AddHook(FilterMessage);
                _usingFilter = true;
            }

            if (_usingFilter && value == false)
            {
                _source.RemoveHook(FilterMessage);
                _usingFilter = false;
            }
        }
    }

    public FilterMessage FilterMessageCallback { get; set; }

    public IntPtr WindowHandle { get { return _interopHelper.Handle; } }
}

the code above is used with WPF project, what i want is to use it in ASP.NET under the System.Web.Ui.Page how can I do that if its possible ?

check the link I provided for more details !

thank you !

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Ibraheem Al-Saady
  • 854
  • 3
  • 14
  • 30
  • 1
    Even if you got this working, it would try to do the scan on the web server, not from machine where the user is browsing. The only way to to this is via plugin like flash or silverlight. – Joel Coehoorn Sep 17 '14 at 13:38
  • @JoelCoehoorn can you please guide me more ? – Ibraheem Al-Saady Sep 17 '14 at 14:06
  • What you have is code that runs on a web server. Nothing you do there runs on your users' machines. You need to go back to the drawing board on this. – Joel Coehoorn Sep 17 '14 at 14:55

0 Answers0