The information in this article applies to:
SUMMARY
Sometimes it is convenient for you to create an object such as a semaphore
or file and then allow a child process to inherit the object's handle. This
provides a means for two or more related processes to easily share an
object.
MORE INFORMATION
Win32 API functions that create objects require a SECURITY_ATTRIBUTES
parameter to give a newly created object access-control information and to
determine whether the handle to the object can be inherited.
Type Name ---- ---- DWORD nLength; LPVOID lpSecurityDescriptor; BOOL bInheritHandle; Secure Win32 operating systems such as Microsoft Windows NT use the lpSecurityDescriptor member to enforce how and by which processes an object is accessed. Because Windows 95 does not have a security system, it ignores lpSecurityDescriptor. Like Microsoft Windows NT, Windows 95 uses the bInheritHandle member to determine whether an object's handle can be inherited by child processes. To initialize a SECURITY_ATTRIBUTES structure so that a handle can be inherited, set bInheritHandle to TRUE. The following code snippet shows how to create a mutex with an inheritable handle:
To prevent the handle from being inherited, set bInheritHandle to FALSE. The following code example demonstrates creating a mutex with a noninheritable handle:
You can also prevent a handle to an object from being inherited by specifying NULL in the call to Win32 object creation API function instead of specifying a pointer to a SECURITY_ATTRIBUTES structure. This is equivalent to setting bInheritHandle to FALSE and lpSecurityDescriptor to NULL. For example:
Cross-Platform Compatibility InformationKeep in mind that while Windows 95 does not have a security system, Windows NT does. Windows 95 ignores the lpSecurityDescriptor member of the SECURITY_ATTRIBUTES, but Windows NT uses it. If access to the object needs to be controlled in a specific way on Windows NT, then the lpSecurityDescriptor should be initialized by calling the Win32 security API functions. Additional query words: 4.00
Keywords : |
Last Reviewed: September 21, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |