type
PJobObjectBasicProcessIDList = ^TJobObjectBasicProcessIDList;
TJobObjectBasicProcessIDList =
Record
NumberOfAssignedProcesses : DWORD;
NumberOfProcessIdsInList : DWORD;
ProcessIdList :
Array[0..0]
of ULONG;
End;
const
{$IFDEF UNICODE}
AWSuffix = '
W';
{$ELSE}
AWSuffix = '
A';
{$ENDIF UNICODE}
const
JOB_OBJECT_ASSIGN_PROCESS = $0001;
{$EXTERNALSYM JOB_OBJECT_ASSIGN_PROCESS}
JOB_OBJECT_SET_ATTRIBUTES = $0002;
{$EXTERNALSYM JOB_OBJECT_SET_ATTRIBUTES}
JOB_OBJECT_QUERY = $0004;
{$EXTERNALSYM JOB_OBJECT_QUERY}
JOB_OBJECT_TERMINATE = $0008;
{$EXTERNALSYM JOB_OBJECT_TERMINATE}
JOB_OBJECT_SET_SECURITY_ATTRIBUTES = $0010;
{$EXTERNALSYM JOB_OBJECT_SET_SECURITY_ATTRIBUTES}
JOB_OBJECT_ALL_ACCESS = STANDARD_RIGHTS_REQUIRED
or SYNCHRONIZE
or $1F ;
{$EXTERNALSYM JOB_OBJECT_ALL_ACCESS}
//
// Extended Limits
//
JOB_OBJECT_LIMIT_PROCESS_MEMORY = $00000100;
{$EXTERNALSYM JOB_OBJECT_LIMIT_PROCESS_MEMORY}
JOB_OBJECT_LIMIT_JOB_MEMORY = $00000200;
{$EXTERNALSYM JOB_OBJECT_LIMIT_JOB_MEMORY}
JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION = $00000400;
{$EXTERNALSYM JOB_OBJECT_LIMIT_DIE_ON_UNHANDLED_EXCEPTION}
JOB_OBJECT_LIMIT_BREAKAWAY_OK = $00000800;
{$EXTERNALSYM JOB_OBJECT_LIMIT_BREAKAWAY_OK}
JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK = $00001000;
{$EXTERNALSYM JOB_OBJECT_LIMIT_SILENT_BREAKAWAY_OK}
JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE = $00002000;
{$EXTERNALSYM JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE}
const
function CreateJobObjectA(lpJobAttributes: PSecurityAttributes; lpName: LPCSTR): THANDLE;
stdcall;
{$EXTERNALSYM CreateJobObjectA}
function CreateJobObjectW(lpJobAttributes: PSecurityAttributes; lpName: LPCWSTR): THANDLE;
stdcall;
{$EXTERNALSYM CreateJobObjectW}
function CreateJobObject(lpJobAttributes: PSecurityAttributes; lpName: LPCTSTR): THANDLE;
stdcall;
{$EXTERNALSYM CreateJobObject}
function OpenJobObjectA(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: LPCSTR): THANDLE;
stdcall;
{$EXTERNALSYM OpenJobObjectA}
function OpenJobObjectW(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: LPCWSTR): THANDLE;
stdcall;
{$EXTERNALSYM OpenJobObjectW}
function OpenJobObject(dwDesiredAccess: DWORD; bInheritHandle: BOOL; lpName: LPCTSTR): THANDLE;
stdcall;
{$EXTERNALSYM OpenJobObject}
function AssignProcessToJobObject(hJob, hProcess: THANDLE): BOOL;
stdcall;
{$EXTERNALSYM AssignProcessToJobObject}
function TerminateJobObject(hJob: THANDLE; uExitCode: UINT): BOOL;
stdcall;
{$EXTERNALSYM TerminateJobObject}
function IsProcessInJob(ProcessHandle, JobHandle: THANDLE;
var Result_: BOOL): BOOL;
stdcall;
{$EXTERNALSYM IsProcessInJob}
Function QueryInformationJobObject(hJob : THandle;
JobObjectInformationClass : TJobObjectInfoClass;
lpJobObjectInformation : Pointer;
cbJobObjectInformationLength : DWORD;
lpReturnLength : PDWORD) : Bool;
StdCall;
External Kernel32
Name '
QueryInformationJobObject';
function CreateJobObjectA;
external kernel32
name '
CreateJobObjectA';
function CreateJobObjectW;
external kernel32
name '
CreateJobObjectW';
function CreateJobObject;
external kernel32
name '
CreateJobObject' + AWSuffix;
function OpenJobObjectA;
external kernel32
name '
OpenJobObjectA';
function OpenJobObjectW;
external kernel32
name '
OpenJobObjectW';
function OpenJobObject;
external kernel32
name '
OpenJobObject' + AWSuffix;
function AssignProcessToJobObject;
external kernel32
name '
AssignProcessToJobObject';
function TerminateJobObject;
external kernel32
name '
TerminateJobObject';
function IsProcessInJob;
external kernel32
name '
IsProcessInJob';