[DllImport("kernel32.dll")]
static extern bool SetInformationJobObject(IntPtr hJob,
JOBOBJECTINFOCLASS JobObjectInfoClass, IntPtr lpJobObjectInfo,
uint cbJobObjectInfoLength);
<DllImport("kernel32.dll", SetLastError:=True)> _
Private Shared Function SetInformationJobObject(hJob As IntPtr, JobObjectInfoClass As JOBOBJECTINFOCLASS, lpJobObjectInfo As IntPtr, cbJobObjectInfoLength As UInteger) As Boolean
End Function
JOBOBJECT_BASIC_LIMIT_INFORMATION
JOBOBJECT_EXTENDED_LIMIT_INFORMATION
None.
Please add some!
Please add some!
Dim j_handle As IntPtr
'Create new Job
j_handle = CreateJobObject(Nothing, Nothing)
'Create job info structure
Dim info As New JOBOBJECT_BASIC_LIMIT_INFORMATION()
'Set process limit count to one
info.ActiveProcessLimit = &H1
'Set job info flags to activate process limiting
info.LimitFlags = &H8
'Get length of job limit structure
Dim length As Integer = Marshal.SizeOf(GetType(JOBOBJECT_BASIC_LIMIT_INFORMATION))
'Create a pointer to our structure
Dim basicInfoPtr As IntPtr = Marshal.AllocHGlobal(length)
Marshal.StructureToPtr(info, basicInfoPtr, False)
'Store the job information settings to the job object
Dim intreturn As Integer = SetInformationJobObject(j_handle, JOBOBJECTINFOCLASS.BasicLimitInformation, basicInfoPtr, CUInt(length))
If Not SetInformationJobObject(j_handle, JOBOBJECTINFOCLASS.BasicLimitInformation, basicInfoPtr, CUInt(length)) Then
Throw New Exception(String.Format("Unable to set information. Error: {0}", Marshal.GetLastWin32Error()))
End If
Do you know one? Please contribute it!