Click here to Skip to main content
15,896,606 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I would like to ask you, how to catch scanner button event by WIA 2.0 on Windows 7.

This code not working:
C#
Device device;
DeviceManagerClass dManager = new DeviceManagerClass();
CommonDialogClass cdlg = new CommonDialogClass();
device = cdlg.ShowSelectDevice(WiaDeviceType.ScannerDeviceType, false, false);
dManager.RegisterEvent(EventID.wiaEventScanImage, device.DeviceID);
dManager.OnEvent += new _IDeviceManagerEvents_OnEventEventHandler(device_OnEvent);


Maybe, there is problem with scanner and win 7. I use HP DeskJet F2180. And if I dont have install HP softwares (All-in-one), pushing scanner button do nothing - windows 7 dont know that button was pressed. With installed HP softwares scanner button execute some HP scaner software, but I want catch this event in my aplication.

I had older HP scanner and when I pushed scanner button, on WinXP was showed box with programs (these programs can be changed by windows registry) or my program handle event. But Window 7 do/show nothing.

Thanks for any reply.

Pav.
Posted
Updated 8-Feb-11 2:04am
v3
Comments
Software_Magic 20-Apr-12 18:52pm    
I have same issue. I think this not working by a normal way. I think usb drivers and app of HP is dedicated to force all function of All in One devices only with HP software. I think also for solve this issue is needed to catch event not by WIA libraries but with USB control. I don't try any solution, this is only a mind. This is only way for solve issue (I think). Scuse me for my bad english.

1 solution

Have you been to this web site yet?

http://msdn.microsoft.com/en-us/library/ms630368(v=vs.85).aspx[^]

At the bottom of the page, there's a link to sample code.

I hate to do it, but here's a link to a similar question (regarding Vista, but Win7 is just Vista in a better-fitting suit) on another site:

http://stackoverflow.com/questions/8966/using-c-wia-version-2-0-on-vista-to-scan[^]

If neirther of those links help, google returned 12,000 results for "c# WIA 2.0".
 
Share this answer
 
v3
Comments
rrrd 8-Feb-11 9:09am    
Thanks for reply.
Of course. I red msdn, but most of codes is in C++ and in WIA automation layer - there is similar code what I posted, but not working on Windows 7 with HP.
Google have many results, I red many of them, but only few is about event handling on C# for WIA and these solutions are for XP or not working.
My problem is not "how to work with WIA in c#", I have already my aplication and it can scan and change properties of scanner. Only catching event (button was pressed) is problem and I cant find working solution for Windows 7.
Pav.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900