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

ID: Q162960

1.25 1.30 1.30a 1.30c WINDOWS kbprg

The information in this article applies to:

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
Keywords          : kbWin32s 
Version           : 1.25 1.30 1.30a 1.30c
Platform          : WINDOWS

Last Reviewed: February 2, 1997