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

IsProcessInJob (kernel32)
 
.
Summary
TODO - a short description

C# Signature:

[DllImport ("kernel32.dll")]

public static extern bool IsProcessInJob (IntPtr Process, IntPtr Job, out bool Result);

VB Signature:

User-Defined Types:

Alternative Managed API:

None!!!

Notes:

Tips & Tricks:

English:

Process - A handle to the process to be tested. The handle must have the PROCESS_QUERY_INFORMATION access right.

Job - A handle to the job. If this parameter is NULL, the function tests if the process is running under any job.If this parameter is not NULL, the handle must have the JOB_OBJECT_QUERY access right.

Result - A pointer to a value that receives TRUE if the process is running in the job, and FALSE otherwise.

Return Value - 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.

Russian:

Process - дескриптор процесса, должен иметь доступ PROCESS_QUERY_INFORMATION

Job - дескриптор задания, должен иметь доступ JOB_OBJECT_QUERY, если он IntPtr.Zero то проверяется, находится ли процесс в каком-либо задании.

Result - если true - процесс в задании, false - не в задании

Return Value - если все успешно - true, если ошибка - false.

Sample Code:

[StructLayout(LayoutKind.Sequential)]

public class SecurityAttributes

{

  public int nLength; //Useless field = 0
  public IntPtr pSecurityDescriptor; //хз))
  public bool bInheritHandle; //Возможность наследования

  public SecurityAttributes ()
  {
     this.bInheritHandle = true;
     this.nLength = 0;
     this.pSecurityDescriptor = IntPtr.Zero;
  }
}

[DllImport("kernel32.dll")]

public static extern IntPtr GetCurrentProcess();

[DllImport("kernel32.dll")]

public static extern bool CloseHandle(IntPtr Object);

[DllImport("kernel32.dll",EntryPoint="CreateJobObjectW", CharSet=CharSet.Unicode)]

public static extern IntPtr CreateJobObject(SecurityAttributes JobAttributes, string lpName);

[DllImport("kernel32.dll")]

public static extern bool AssignProcessToJobObject(IntPtr Job, IntPtr Process);

[DllImport ("kernel32.dll")]

public static extern bool IsProcessInJob (IntPtr Process, IntPtr Job, out bool Result);

public static void Main ()

{

  bool Is;
  IntPtr Job = CreateJobObject (null, "Хуй =)");
  IntPtr Job = CreateJobObject (null, "Хуй");
  AssignProcessToJobObject(Job, GetCurrentProcess());

  IsProcessInJob (GetCurrentProcess (), Job, out Is);
  Console.WriteLine ("That process in that job: " + Is);

  IsProcessInJob (GetCurrentProcess (), IntPtr.Zero, out Is);
  Console.WriteLine ("That process in any job: " + Is);

  CloseHandle (Job);
  Console.ReadKey();

}

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