PRB: COMM (TTY) Sample Does Not Work on Windows 95

Last reviewed: September 25, 1995
Article ID: Q128787
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows 95 version 4.0
    

SYMPTOMS

The Win32 COMM (old TTY) sample that ships with Visual C++ version 2.x and the Windows 95 SDK (pre-release) does not work correctly under Windows 95 M8 builds and later. The problem involves assigning values to the Offset member of the OVERLAPPED structure which is one of the arguments to the WriteFile function call.

The observed behavior is that the COMM sample writes only one byte to the serial port. No other data is transmitted after the first byte.

CAUSE

The documentation for the OVERLAPPED structure explicitly states that the Offset and OffsetHigh members must be set to 0 when reading from or writing to a named pipe or communications device. This was not done in the sample.

RESOLUTION

  1. Delete the following line from the WriteCommByte() function in the sample:

    WRITE_OS( npTTYInfo ).Offset += dwBytesWritten ;

  2. Add the following lines to the CreateTTYInfo() function:

    WRITE_OS( npTTYInfo ).Offset = 0 ; WRITE_OS( npTTYInfo ).OffsetHigh = 0 ;

STATUS

This is a problem with the sample, not with Windows 95. Windows 95 correctly implements WriteFile() and use of the OVERLAPPED structure.


Additional reference words: 4.00
KBCategory: kbprg kbprb
KBSubcategory: BseComm


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: September 25, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.