-3

I am trying to build a window service which will run in background for card reader, I will take card's data on a textbox . My question is : When someone swipes a card on a card reader that window service WINFORM should take card;s data on a textbox. How can I achieve this.

or,

IF any one can tell me just that how to execute a WINFORM when card swipes, that would work also

Thanks

user2454135
  • 59
  • 2
  • 12
  • 2
    Your question is very vague. If you have written the attendance software, simply modify it to display the swiped cards information. If not, you will have to specify how that software works and probably work on a way to forward the information to that application. – Daniel B Oct 06 '13 at 18:22

2 Answers2

1

Windows services aren't supposed to show any kind of UI to the user, they run as completely background task that take no input from the user and show no output or status to them. If you require a service to "talk" with the user, the normal practice is to split the project in 2 different programs, one being the service itself, which is a UI-less thing that does the background processing, and a normal user app, maybe ran at login, that shows notifications and communicates with the service. Consider also that services survive logoff and logon, and there may be many users logged at a given time, so it doesn't make sense to show a dialog to anyone.

My suggestion would be to turn the service into a normal program, that the installer configures to run at startup, and it does the monitoring of the card reader and displaying of the popups asking details for the user. Since there will be no background work, other than monitoring, and if the form is absolute required, it doesn't makes sense to monitor without a user logged in, I don't think a service is the best choice.

Alejandro
  • 7,290
  • 4
  • 34
  • 59
0

I have seen two type of card readers:

1 - plugs into your keyboard port and acts as a keyboard (can also plug into a USB port, but still simulates a keyboard). When a card is swiped the info is written to whatever application and text field currently has focus.

2 - Has some kind of hardware driver (most likely a USB driver, possibly Serial or other).

If you aren't sure which you have then open notepad, make sure it has focus, and swipe the card. If the details show in notepad then you have #1. If they don't, then you probably have #2

If your reader is #1 then you can put some code into the Textbox's TextChanged event to do what you need (I presume you can add code to the application as you said you are building it).

If your reader is #2 then it really depends on the driver it uses. Some will likely provide an API you can integrate with, but you will need to find documentation.

Do you have a model number and manufacturer for your card reader?

Zippit
  • 1,673
  • 1
  • 11
  • 11
  • manufacturer: MagTek Modelno.: 21040145. I have done exactly the same as in #1, however to achieve this I need to open an app to take card's data. But here data needs to be taken without opening any app. Is it achievable? – user2454135 Oct 07 '13 at 06:36
  • You could try a system-wide keyboard hook. Here is an article on implementing one in C#: http://blogs.msdn.com/b/toub/archive/2006/05/03/589423.aspx. But this won't work from a windows service due to security: http://social.msdn.microsoft.com/Forums/vstudio/en-US/00590009-b118-4489-9347-02b5f734d219/using-hooks-in-windows-service?forum=csharpgeneral. Is it good enough to build your app as a WinForms app and configure it to autostart? It could run in the notification area of the taskbar. – Zippit Oct 07 '13 at 13:17