You do AssignProcessToJobObject
and it fails with "access denied" but only when you are running in the debugger. Why is this?
相关问题
- Sorting 3 numbers without branching [closed]
- Multiple sockets for clients to connect to
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
This one puzzled me for for about 30 minutes.
First off, you probably need a UAC manifest embedded in your app (as suggested here). Something like this:
Secondly (and this is the bit I got stuck on), when you are running your app under the debugger, it creates your process in a job object. Which your child process needs to be able to breakaway from before you can assign it to your job. So (duh), you need to specify
CREATE_BREAKAWAY_FROM_JOB
in the flags forCreateProcess
).If you weren't running under the debugger, or your parent process were in the job, this wouldn't have happened.
This seems to bite me quite often, and while good, 1800INFORMATION's post doesn't seem to include a number of reasons and fixes that seem helpful, so it seem worthwhile to post a summary of why I've seen this happen.