Platform SDK: DLLs, Processes, and Threads

OpenJobObject

The OpenJobObject function opens an existing job object.

HANDLE OpenJobObject(
  DWORD dwDesiredAccess,  // access right
  BOOL bInheritHandles,   // inheritance state
  LPCTSTR lpName          // job name
);

Parameters

dwDesiredAccess
[in] Specifies the desired access mode to the job object. This parameter can be one or more of the following values.
Value Meaning
MAXIMUM_ALLOWED Specifies maximum access rights to the job object that are valid for the caller.
JOB_OBJECT_ASSIGN_PROCESS Specifies the assign process access right to the object. Allows processes to be assigned to the job.
JOB_OBJECT_SET_ATTRIBUTES Specifies the set attribute access right to the object. Allows job object attributes to be set.
JOB_OBJECT_QUERY Specifies the query access right to the object. Allows job object attributes and accounting information to be queried.
JOB_OBJECT_TERMINATE Specifies the terminate access right to the object. Allows termination of all processes in the job object.
JOB_OBJECT_SET_SECURITY_ATTRIBUTES Specifies the security attributes access right to the object. Allows security limitations on all processes in the job object to be set.
JOB_OBJECT_ALL_ACCESS Specifies the full access right to the job object.

bInheritHandles
[in] Specifies whether the returned handle is inherited when a new process is created. If this parameter is TRUE, the new process inherits the handle.
lpName
[in] Pointer to a null-terminated string specifying the name of the job to be opened. Name comparisons are case sensitive.

Return Values

If the function succeeds, the return value is a handle to the job. The handle provides the requested access to the job.

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

Remarks

To associate a process with a job, use the AssignProcessToJobObject function.

Requirements

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Unsupported.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Kernel32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows 2000.

See Also

Processes and Threads Overview, Process and Thread Functions, AssignProcessToJobObject