Platform SDK: Interprocess Communications

SetHandleInformation

The SetHandleInformation function sets certain properties of an object handle. The information is specified as a set of bit flags.

BOOL SetHandleInformation(
  HANDLE hObject,  // handle to object
  DWORD dwMask,    // flags to change
  DWORD dwFlags    // new values for flags
);

Parameters

hObject
[in] Handle to an object. The SetHandleInformation function sets information associated with this object handle.

You can specify a handle to one of the following types of objects: access token, event, file, file mapping, job, mailslot, mutex, pipe, printer, process, registry key, semaphore, serial communication device, socket, thread, or waitable timer.

Windows 2000: This parameter can also be a handle to a console input buffer or a console screen buffer.

dwMask
[in] A mask that specifies the bit flags to be changed. Use the same flag constants shown in the description of dwFlags.
dwFlags
[in] A set of bit flags that specify properties of the object handle. This parameter can be one of the following values.
Value Meaning
HANDLE_FLAG_INHERIT If this flag is set, a child process created with the bInheritHandles parameter of CreateProcess set to TRUE will inherit the object handle.
HANDLE_FLAG_PROTECT_FROM_CLOSE If this flag is set, calling the CloseHandle function will not close the object handle.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

To set or clear the associated bit flag in dwFlags, you must set a change mask bit flag in dwMask.

Requirements

  Windows NT/2000: Requires Windows NT 3.51 or later.
  Windows 95/98: Unsupported.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.

See Also

Handles and Objects Overview, Handle and Object Functions, CreateProcess, CloseHandle, GetHandleInformation