How does a child process inherit the parent process's handles, created with CreateFile? Where are these handles put? How to use them?
Posted on 2002-08-16 15:11:23 by Vaxon
There are two ways to do it, as far as I know.

Mark the file handle inheritable. (This is done when you call CreateFile. Have a look at SECURITY_ATTRIBUTES structure.)
Then, when calling CreateProcess to spawn the child, pass TRUE as bInheritHandles.

the API func: DuplicateHandle
MSDN says all. :)

After you have done this (either way), the object (FILE, here) is ready in the child pocess's kernel object table.
For the first method, the handle in child process is exactly the same as in the parent process.
For the second one, it is returned in pTargetHandle, if i recall correctly.
You have to do some ipc anyway.
Posted on 2002-08-19 04:32:30 by C.Z.
Thanks BOMB01:)
Posted on 2002-08-21 07:42:26 by Vaxon