Microsoft KB Archive/68942

BUG: sopen Fails When Called From a Windows DLL

PSS ID Number: Q68942 Article last modified on 04-26-1993

2.03 2.10 3.00 WINDOWS

Summary: The sopen function provided by Microsoft C versions 6.0 and 6.0a is listed as being compatible with Windows dynamic-link libraries (DLLs). However, when sopen is called from a DLL, it ignores the file-sharing flags and fails to perform as documented.

More Information: When it is called from a DLL, sopen refers to the C library variable _osmajor to determine if the MS-DOS version is 3.0 or later. These versions of DOS support file sharing. When sopen makes this check, _osmajor contains the value 0 (zero), and sopen ignores the file-share flags. The _osmajor variable is 0 because no C run-time library initialization is performed for Windows DLLs. This problem can be avoided by performing the following two steps before using sopen: 1. Declare an unsigned char _osmajor. 2. Assign _osmajor the value 3 or higher. Microsoft has confirmed this to be a problem in Windows versions 2.03 and 2.1 and in the DLL libraries for Windows version 3.0. We are researching this problem and will post new information here as it becomes available.

Additional reference words: 2.03 2.10 3.00 6.00 6.00a KBCategory: KBSubcategory: KrFileioFileshare Copyright Microsoft Corporation 1993.