In my tests on Windows 2000, the hardware accessibility layer (HAL) virtualizes the ports so simply testing the state of DSR/CTS/DTR gives you the state that Windows wants your code to see... in the best interests of your PC's security.

On occasion, the MSR state appears to be the state of the port the last time it was actually opened by a DOS app... I don't believe it is guaranteed to be the <U>actual</U> port state at any given moment (at least for CTS/DSR).
For example, I can query my external modem's DSR line only after I switch off the Fax service, and only if I actually open the port before prodding as the MSR. Once I open the port at least once, sucessive tests show the same result even if I turn the modem off... but if I open the port, the MSR value returned by Windows will instantly refresh the status accurately.
However, if I then restart the Fax service and continue running my tests on the MSR status (without actually opening the port in the DOS app), I still see the same states in the MSR registers... even though the port has now been OPEN'ed by the fax monitor service, not my DOS app.
Summary: It's not possible to get 100% reliable results from a DOS app under Windows 2000 by testing the [virtualized] modem status register. The same should apply equally to NT and XP since they employ the same HAL control.
------------------
Lance
PowerBASIC Support
mailto:[email protected][email protected]</A>
Leave a comment: