网站首页  词典首页

请输入您要查询的函数:

 

术语 assignprocesstojobobject
释义 AssignProcessToJobObject
语法:
C++
BOOL WINAPI AssignProcessToJobObject(
__in HANDLE hJob,
__in HANDLE hProcess
);
AssignProcessToJobObject功能
指定一个现有的程序,作业对象。
参数
hJob [in]
句柄的工作对象是该过程将相关。在CreateJobObject或OpenJobObject函数返回此句柄。句柄必须有JOB_OBJECT_ASSIGN_PROCESS访问权限。有关更多信息,请参见作业对象的安全和访问权限。
hProcess [in]
一个句柄,与作业对象关联的过程。这个过程必须尚未被分配到一个工作,如果是的话,函数ERROR_ACCESS_DENIED失败。句柄必须有PROCESS_SET_QUOTA和PROCESS_TERMINATE访问权限。有关更多信息,请参见过程的安全性和访问权限。
终端服务:在工作的所有程序必须运行在相同的工作会议。
返回值
如果函数成功,返回值为非零。
如果函数失败,返回值是零。为了获得更多错误信息,调用GetLastError。
备注
在您联想到工作的进程对象使用AssignProcessToJobObject,这个过程是受这份工作规定的限制。要为就业限制,使用SetInformationJobObject功能。
如果工作有一个用户模式的时间限制,时间限制已经耗尽,AssignProcessToJobObject失败,指定的进程终止。如果时限将由关联的进程超出AssignProcessToJobObject仍然成功。然而,违反时限将报告。如果工作有一个活跃的进程限制,以及限制将在这一进程中关联超出AssignProcessToJobObject失败,并且指定的进程终止。
通过与工作具有内存限制关联的进程执行的内存操作受内存限制。在它面前的是与工作相关的进程执行的内存操作不检查AssignProcessToJobObject。
如果进程已经在运行和工作的安全限制,AssignProcessToJobObject可能会失败。例如,如果主进程令牌包含本地管理员组,但工作对象的安全限制JOB_OBJECT_SECURITY_NO_ADMIN,功能失败。如果工作有保障的限制JOB_OBJECT_SECURITY_ONLY_TOKEN,这一进程必须创建暂停。要创建一个暂停的过程,请与CREATE_SUSPENDED标志CreateProcess函数。
一个进程可以只与一个工作。一个进程继承了它,并增加了与会计信息工作的工作范围。如果一个进程是与工作相关,它创建的所有进程是默认情况下与该工作相关。要创建一个进程,它不属于同一工作的一部分,请与CREATE_BREAKAWAY_FROM_JOB旗CreateProcess函数。
如果进程正被监视的程序兼容性助手(PCA)的,它是把工作放在一个兼容性。因此,这一进程必须创建使用CREATE_BREAKAWAY_FROM_JOB然后才可以在另一个职位上。或者,您可以嵌入一个应用程序清单,指定一个用户帐户控制(UAC)在应用程序和PCALevel不添加进程的兼容性工作。有关更多信息,请参阅用户帐户控制兼容性应用开发需求。
要编译的应用程序使用此功能,定义_WIN32_WINNT为0x0500或更高版本。有关详细信息,请参阅使用Windows头。
要求:
最低支持:client-Windows 2000专业版
最低支持server-Windows 2000服务器
HeaderWinbase.h(头文件:winuser.h)
LibraryKernel32.lib
DLLKernel32.dll
参见
CreateJobObject
CreateProcess的
招聘对象
OpenJobObject
进程和线程函数
SetInformationJobObject
如果有任何问题和意见,请发送给微软(wsddocfb@microsoft.com)
生成日期:2009年8月27日
==英文原文==AssignProcessToJobObject Function
Assigns a process to an existing job object.
Syntax
C++
BOOL WINAPI AssignProcessToJobObject(
__in HANDLE hJob,
__in HANDLE hProcess
);
Parameters
hJob [in]
A handle to the job object to which the process will be associated. The CreateJobObject or OpenJobObject function returns this handle. The handle must have the JOB_OBJECT_ASSIGN_PROCESS access right. For more information, see Job Object Security and Access Rights .
hProcess [in]
A handle to the process to associate with the job object. The process must not already be assigned to a job; if it is, the function fails with ERROR_ACCESS_DENIED. The handle must have the PROCESS_SET_QUOTA and PROCESS_TERMINATE access rights. For more information, see Process Security and Access Rights .
Terminal Services: All processes within a job must run within the same session as the job.
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 .
Remarks
After you associate a process with a job object using AssignProcessToJobObject, the process is subject to the limits set for the job. To set limits for a job, use the SetInformationJobObject function.
If the job has a user-mode time limit, and the time limit has been exhausted, AssignProcessToJobObject fails and the specified process is terminated. If the time limit would be exceeded by associating the process, AssignProcessToJobObject still succeeds. However, the time limit violation will be reported. If the job has an active process limit, and the limit would be exceeded by associating this process, AssignProcessToJobObject fails, and the specified process is terminated.
Memory operations performed by a process associated with a job that has a memory limit are subject to the memory limit. Memory operations performed by the process before it was associated with the job are not examined by AssignProcessToJobObject.
If the process is already running and the job 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 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. A process inherits limits from the job it is associated with and adds its accounting information to the job. If a process is associated with a job, all processes it creates are associated with that job by default. To create a process that is not part of the same job, call the CreateProcess function with the CREATE_BREAKAWAY_FROM_JOB flag.
If the process is being monitored by the Program Compatibility Assistant (PCA), it is placed into a compatibility job. Therefore, the process must be created using CREATE_BREAKAWAY_FROM_JOB before it can be placed in another job. Alternatively, you can embed an application manifest that specifies a User Account Control (UAC) level in your application and PCA will not add the process to the compatibility job. For more information, see Application Development Requirements for User Account Control Compatibility .
To compile an application that uses this function, define _WIN32_WINNT as 0x0500 or later. For more information, see Using the Windows Headers .
Requirements
Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryKernel32.lib
DLLKernel32.dll
See Also
CreateJobObject
CreateProcess
Job Objects
OpenJobObject
Process and Thread Functions
SetInformationJobObject
Send comments about this topic to Microsoft
Build date: 8/27/2009
==原始网址==http://msdn.microsoft.com/en-us/library/ms681949(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 11:27:55