Skip to content

Latest commit

 

History

History
135 lines (90 loc) · 5.99 KB

nf-jobapi2-createjobobjectw.md

File metadata and controls

135 lines (90 loc) · 5.99 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:jobapi2.CreateJobObjectW
CreateJobObjectW function (jobapi2.h)
Creates or opens a job object. (CreateJobObjectW)
CreateJobObject
CreateJobObject function
CreateJobObjectA
CreateJobObjectW
_win32_createjobobject
base.createjobobject
winbase/CreateJobObject
winbase/CreateJobObjectA
winbase/CreateJobObjectW
base\createjobobject.htm
backup
ca6a044f-67ed-4a9c-9aeb-69dd77652854
12/05/2018
CreateJobObject, CreateJobObject function, CreateJobObjectA, CreateJobObjectW, _win32_createjobobject, base.createjobobject, winbase/CreateJobObject, winbase/CreateJobObjectA, winbase/CreateJobObjectW
jobapi2.h
Windows.h, Jobapi2.h
Windows
Windows XP [desktop apps only]
Windows Server 2003 [desktop apps only]
CreateJobObjectW (Unicode) and CreateJobObjectA (ANSI)
Kernel32.lib
Kernel32.dll
Windows
19H1
CreateJobObjectW
jobapi2/CreateJobObjectW
c++
APIRef
kbSyntax
DllExport
Kernel32.dll
API-MS-Win-Core-job-l2-1-0.dll
kernel32legacy.dll
API-Ms-Win-Core-Kernel32-Legacy-Ansi-L1-1-0.dll
API-MS-Win-Core-Job-L2-1-1.dll
CreateJobObject
CreateJobObjectA
CreateJobObjectW

CreateJobObjectW function

-description

Creates or opens a job object.

-parameters

-param lpJobAttributes [in, optional]

A pointer to a SECURITY_ATTRIBUTES structure that specifies the security descriptor for the job object and determines whether child processes can inherit the returned handle. If lpJobAttributes is NULL, the job object gets a default security descriptor and the handle cannot be inherited. The ACLs in the default security descriptor for a job object come from the primary or impersonation token of the creator.

-param lpName [in, optional]

The name of the job. The name is limited to MAX_PATH characters. Name comparison is case-sensitive.

If lpName is NULL, the job is created without a name.

If lpName matches the name of an existing event, semaphore, mutex, waitable timer, or file-mapping object, the function fails and the GetLastError function returns ERROR_INVALID_HANDLE. This occurs because these objects share the same namespace.

The object can be created in a private namespace. For more information, see Object Namespaces.

Terminal Services:  The name can have a "Global\" or "Local\" prefix to explicitly create the object in the global or session namespace. The remainder of the name can contain any character except the backslash character (\). For more information, see Kernel Object Namespaces.

-returns

If the function succeeds, the return value is a handle to the job object. The handle has the JOB_OBJECT_ALL_ACCESS access right. If the object existed before the function call, the function returns a handle to the existing job object and GetLastError returns ERROR_ALREADY_EXISTS.

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

-remarks

When a job is created, its accounting information is initialized to zero, all limits are inactive, and there are no associated processes. To assign a process to a job object, use the AssignProcessToJobObject function. To set limits for a job, use the SetInformationJobObject function. To query accounting information, use the QueryInformationJobObject function.

All processes associated with a job must run in the same session. A job is associated with the session of the first process to be assigned to the job.

Windows Server 2003 and Windows XP:  A job is associated with the session of the process that created it.

To close a job object handle, use the CloseHandle function. The job is destroyed when its last handle has been closed and all associated processes have exited. However, if the job has the JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE flag specified, closing the last job object handle terminates all associated processes and then destroys the job object itself.

To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers.

-see-also

AssignProcessToJobObject

CloseHandle

Job Objects

Process and Thread Functions

QueryInformationJobObject

SECURITY_ATTRIBUTES

SetInformationJobObject