[This is preliminary documentation and subject to change.]
The AssignProcessToJobObject function associates a process with an existing job object.
BOOL AssignProcessToJobObject(
HANDLE hJob,
HANDLE hProcess
);
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.
After you associate a process with a job object using AssignProcessToJobObject, the process is subject to the limits set for the job object. To set limits for a job object, use the SetInformationJobObject function.
If the job object has a user-mode time limit, and the time limit has been exhausted, AssignProcessToJobObject fails and the specified process is terminated. If the job object has an active process limit, and the limit would be exceeded by associating this process, AssignProcessToJobObject fails, and the specified process is terminated.
If the process is already running and the job object has security limitations, AssignProcessToJobObject may fail. For example, if the primary token of the process contains the local administrators group, but the job object has the security limitation JOB_OBJECT_SECURITY_NO_ADMIN, the function fails. If the job object has the security limitation JOB_OBJECT_SECURITY_ONLY_TOKEN, the process must be created suspended. To create a suspended process, call the CreateProcess function with the CREATE_SUSPENDED flag.
A process can be associated only with a single job object. If a process is associated with a job object, all processes it creates are also associated with that job object. A process inherits limits from the job object it is associated with and adds its accounting information to the job object.
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winbase.h.
Import Library: Use kernel32.lib.
Processes and Threads Overview, Process and Thread Functions, , Process and Thread Functions, Processes and Threads Overview, Process and Thread Functions, Processes and Threads OverviewCreateJobObject, OpenJobObject, SetInformationJobObject