INFO: 16-bit App Does Not Get Parent's Modified Environment

Last reviewed: January 31, 1997
Article ID: Q162960
The information in this article applies to:
  • Microsoft Win32s, versions 1.25, 1.3, 1.30a, 1.3c

SUMMARY

Win32-based applications running under Win32s can spawn both Windows-based and Win32-based applications by using either WinExec() or CreateProcess(). However, the Windows-based application will not get the modified environment of the parent application.

MORE INFORMATION

In Win32s version 1.2 and later, WinExec() does not pass the environment to the spawned Windows-based application (the 16-bit child). Instead, the child receives the standard global environment strings. This allows the Windows-based application to run, but the child does not receive the modified environment from the parent. This seemed to be a reasonable compromise for a bug that caused a GP Fault in the C start-up code that comes with Microsoft C version 6.0 because most applications do not change the environment for the child. Many application that come with Windows, such as Write and Notepad, were compiled with C version 6.0.

If an application must modify the child's environment, it can spawn the application using CreateProcess() and specify an explicit environment. However, be aware that if the parent exits, the child's environment becomes invalid. This behavior is due to the underlying Windows 3.x operating system.

NOTE: Win32s uses a different mechanism to spawn Win32-based applications, so the problems discussed in this article do not occur when spawning Win32-based applications with WinExec() or CreateProcess().

For more information, please refer to the following article in the Microsoft Knowledge Base:

   ARTICLE-ID: Q102958
   TITLE     : PRB: Passing Modified Environments to Child Processes


KBCategory: kbprg
KBSubcategory: w32s
Additional reference words: 1.25 1.30 1.30a 1.30c gpf gpfault crash



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