Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SetInformationJobObject (kernel32)
 
.
Summary

C# Signature:

[DllImport("kernel32.dll")]
static extern bool SetInformationJobObject(IntPtr hJob,
   JOBOBJECTINFOCLASS JobObjectInfoClass, IntPtr lpJobObjectInfo,
   uint cbJobObjectInfoLength);

VB Signature:

<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

User-Defined Types:

JOBOBJECTINFOCLASS

JOBOBJECT_BASIC_LIMIT_INFORMATION

JOBOBJECT_EXTENDED_LIMIT_INFORMATION

Notes:

None.

Tips & Tricks:

Please add some!

Sample Code:

Please add some!

VB Sample Code:

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

Alternative Managed API:

Do you know one? Please contribute it!

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions