Create service-application for windows XP

Posted on 2006-04-24
Last Modified: 2010-04-05

If using a service isn't a wise thing to do, than other solutions are welcome too. I need to build it from scratch anyway.

The following is what I want to accomplish:
A customer is visiting my trainingfacility. He is checking-in by using his magnet-card.
The magnetcardreader is attached to a serial-com port.

Here is the part the service comes in:
The service-application identified that data is send by the com-port.
The send data contains an identificationnumber of the customer.
The service will update a database to register that the customer is present. (if he scans a second time he will be checked-out).
Also the service will show a windows-popup containing the name and picture of the customer.
The popupscreen will disapear automatically after 3 seconds.

What would be a good way to implement this behaviour?
Can anybody give me some example or guidelines?

Question by:Delphiwizard
    LVL 28

    Expert Comment

    a service is a good idea and fits the needs.

    now the needed imlementation is the trocky part: you don't know/have anything on how to do it?
    1) do you have components for the serial communication part?
    2) do you have the database part covered or are you able to cover it?
    3) is the popup thing really needed? better make that configurable (imagine the case of 10-30 customers visiting at once (not a real life situation, but you never know)

    it's been a while since I last worked with serial communication, but at that time (about 33-4 years ago) I used AsyncFree.
    as database components, it really depends on the backend.

    the implementation itself is pretty simple though:
    - the service will start a listener thread that gets the data from the serial port. when data is available, it is put in a queue and a callback function of somekind is called that get the data from the queue (synchronization is needed here ;) )and makes out the data package in a readable format for the app. this is then put in the DB and the popup (which runs in its own thread)  is fired.

    that should be it.

    Author Comment

    Thank you for your info.
    I don't have any experience with using threads, listening to serialports nor callback (synchronisation) and queing of data. I can cover the databasepart, so we can skip that.
    I don't have any component for the serial communication part, but will buy probably TMS ASync32.

    So as you see a lot of help is needed here.
    LVL 28

    Accepted Solution

    well then, we'll do it one step at a time:
    1) get familiar with TMS ASync 32 (this should be fairly easy, so you can actually write a class that gets the desired data from the card reader)
    2) for threads, you can look over the following examples/tutorials:
    3) queueing data basically implies to use a queue class (TQueue, TObjectQueue for example: add "contnrs" to the uses clause to use them; use push/pop to add get items from the queue)
    4) synchronizing access to a resource can be done in various ways: semaphores, critical sections, mutex, etc. I couldn't find a good tutorial on this for delphi, but the following is pretty good for a begginer:
     Probably the easiest way for a begginer is to use a thread-safe component. I couldn't find in a short period of time a good example for this.
    Personally I prefer using critical sections to do the job. You have more control over things with this :)

    uses SyncObjs;
    global var cs:TCriticalSection = new TCriticalSection;// one per shared resource

          use the resource

    the above pattern will make sure that no critical section will be left locked ;)

    let me know when you bump into issues

    Author Comment

    At the moment I can't do any testing as I have to wait for my own customer to give a GO to the project. So I don't have ASync32 nor a magnetreader.
    The way you describe the way to implement it is not that easily form me to understand as I have no experience with this part of delphi-programming. So some additional help would be greatly appreciated when the project will start.
    LVL 28

    Expert Comment

    well, we answer questions here, solve problems, but we do not help in making projects. there are other sites  (services) for that were you can hire a coder to do part or all of the job.
    we can give you pointers, examples and otherwise information that will help you do your job, but not do your job or part of it for you. it's not ethical.

    the information I have given you in basic design and some examples/tutorials are more than enough to get your on the right tracks. but you have to do the rest yourself and come back when you have problems/issues implementing and we will help you gladly.


    Author Comment

    I understand that.
    Thank you for your directions.


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now