AssignProcessToJobObject失败"拒绝访问"在调试器下运行时错误 [英] AssignProcessToJobObject fails with "Access Denied" error when running under the debugger
问题描述
您做 AssignProcessToJobObject
,它失败并拒绝访问,但只有当你在调试器中运行。这是为什么?
You do AssignProcessToJobObject
and it fails with "access denied" but only when you are running in the debugger. Why is this?
推荐答案
这一次困扰了我30分钟左右。
This one puzzled me for for about 30 minutes.
首先,你可能需要一个UAC舱单嵌入在您的应用程序(<一个href=\"http://stackoverflow.com/questions/53208/how-do-i-automatically-destroy-child-processes-in-windows#53214\">as这里建议)。事情是这样的:
First off, you probably need a UAC manifest embedded in your app (as suggested here). Something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="asInvoker"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
其次(这是我被困在位),当你在调试器下运行你的应用程序,它会创建一个作业对象的过程。您的孩子的过程需要能够从之前您可以将其分配给您的工作,远走他乡。所以,(杜),你需要指定 CREATE_BREAKAWAY_FROM_JOB
中的标志的CreateProcess
)。
如果你没有在调试器下运行,或者你的父进程都在工作,这将不会发生。
If you weren't running under the debugger, or your parent process were in the job, this wouldn't have happened.
这篇关于AssignProcessToJobObject失败&QUOT;拒绝访问&QUOT;在调试器下运行时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!