Opening Files, Compatibility Mode and Windows

Last reviewed: July 22, 1997
Article ID: Q74445
3.00 3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

Opening a file in compatibility mode is a very unfriendly action in a multitasking environment such as Windows. There is never any need to do so; compatibility mode provides support for old MS-DOS (non-Windows) applications however it does not provide additional functionality.

Use the following four guidelines for opening files:

  1. Do not use the _lcreate function, it opens files in compatibility mode. If it is necessary to create a file, immediately close the file and then reopen it with the _lopen function.

  2. Do not use the OF_SHARE_COMPAT option with the _lopen or OpenFile functions. Instead, use one of the other OF_SHARE defines. If no OF_SHARE value is specified, the file is opened in compatibility mode.

  3. When creating a file using MS-DOS interrupts 3Ch or 5Bh, after creating the file, close it and then open it again. The create leaves it in compatibility mode.

  4. When opening a file (MS-DOS interrupts 3Dh or 6Ch), make sure that the file is NOT opened in compatibility mode.

When specifying the open mode and share, do not request more access than required. If a file will only be read, open it in read-only mode EVEN IF EXCLUSIVE ACCESS IS REQUESTED. Do not lock out other access unnecessarily. If an application will only read a file, allow other applications to read the file as well.

Finally, be open to alternatives when opening a file. If a file is being opened to display its contents and an open READ-ONLY, DENY-WRITE fails, try an open READ-ONLY, DENY-NONE.


Additional reference words: 3.00 3.10
KBCategory: kbprg
KBSubcategory: KrFileIO
Keywords : kb16bitonly


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: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.