A child process can inherit several properties and resources from its parent process. You can also prevent a child process from inheriting properties from its parent process. The following can be inherited:
The child process does not inherit the following:
A child process can inherit some of its parent's handles, but not inherit others. To cause a handle to be inherited, you must do two things:
An inherited handle refers to the same object in the child process as it does in the parent process. It also has the same value and access privileges. Therefore, when one process changes the state of the object, the change affects both processes. To use a handle, the child process must retrieve the handle value and "know" the object to which it refers. Usually, the parent process communicates this information to the child process through its command line, environment block, or some form of interprocess communication. The DuplicateHandle() function is useful if a process has an inheritable open handle that you do not want to be inherited by the child process. In this case, use DuplicateHandle() to open a duplicate of the handle that cannot be inherited, then use the CloseHandle() function to close the inheritable handle. You can also use the DuplicateHandle() function to open an inheritable duplicate of a handle that cannot be inherited.
Inheriting Environment Variables
A child process inherits the environment variables of its parent process by default. However, CreateProcess() enables the parent process to specify a different block of environment variables.
Inheriting the Current Directory
The GetCurrentDirectory() function retrieves the current directory of the calling process. A child process inherits the current directory of its parent process by default. However, CreateProcess() enables the parent process to specify a different current directory for the child process. To change the current directory of the calling process, use the SetCurrentDirectory() function.