Read pulses through RS-232

I need to read the output from a magnetic reed device in the PC. The reed device gives a pulse when it sense the metal.

How can I achieve the above mentioned scenario?
It would be best if sample codes are provided.

Which pins do I connect the wires from the magnetic reed device to the RS232 and whether can I connect straight to the pins without any interfacing circuitry?
Output of the reed is 24Vdc (max).

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

>>Output of the reed is 24Vdc (max).

Don't even try to connect that directly to the serial port, it'll just blow up the UART. You need some device that transforms the pulses to a signal with a voltage and impedance that can work with a serial port and adds the necessary protocol logic. Then, see ("Serial Communications in Win32") on how to read the data from the serial port.
Ask this question in the C programming area, the best real time programming experts are there.
jcwhAuthor Commented:
What 24Vdc (max) means is that the reed device can operate with voltages ranging to 24 Vdc (max), therefore, it can also function with 5 Vdc.
The reed is just a magnetic switch that closes when it sense a magnet.
If it is really switch which is only closed or opened ( no voltage is given) You can connect it between  pins 4 and 6 in 9-pin RS232.
These are DTR and DSR lines
Then You should after opening port set DTR line state with

      EscapeCommFunction(hPort, CLRDTR);
      EscapeCommFunction(hPort, SETDTR);

I don't remember which will be appropriate. Try one or the other.

And then You can poll the DSR state with

      GetCommModemStatus    function

WaitCommEvent functon will be also helpfull

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.