ResumeThread失败,返回值-1,程序一直等待
在进程创建的时候用了‘CREATE_SUSPEND’,再将进程放入job管理后,ResumeThread却总是不成功
这是创建进程的部分。
这是相关的job管理部分。黄色部分resumethread总是失败的。
这是什么原因呢?
各位见谅,代码无法拷贝,只能截图。 C windows 进程
[解决办法]
的确是权限的原因。VS调试正常是因为进程运行在调试权限下。
MSDN上说加入作业的进程句柄必需要有PROCESS_SET_QUOTA及PROCESS_TERMINATE权限。
hProcess
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.
或者你在CreateProcess的第6个参数加入CREATE_BREAKAWAY_FROM_JOB试下
CREATE_BREAKAWAY_FROM_JOB
[解决办法]
NORMAL_PRIORITY_CLASS
[解决办法]
CREATE_SUSPENDED