简体   繁体   English

具有两个 dwDesiredAccess 的 OpenProcess function

[英]OpenProcess function with two dwDesiredAccess

Based on microsoft documentation, dwDesiredAccess parameter can be one or more of the process access rights.根据 microsoft 文档,dwDesiredAccess 参数可以是一个或多个进程访问权限。

I want to pass two different dwDesiredAccess (PROCESS_QUERY_INFORMATION and PROCESS_TERMINATE) when I call openProcess function.当我调用 openProcess function 时,我想传递两个不同的 dwDesiredAccess(PROCESS_QUERY_INFORMATION 和 PROCESS_TERMINATE)。 Can anyone show me how to call the function?谁能告诉我如何调用 function?

HANDLE hprocess = OpenProcess(PROCESS_QUERY_INFORMATION, 0, static_cast<DWORD>(proc.th32ProcessID));

Please note that the above code is for one access right.请注意,上面的代码是针对一种访问权限的。

Like most Win32 functions where you can set multiple parameters in a single argument, you need to simply bitwise OR in the parameters together:像大多数 Win32 函数一样,您可以在单个参数中设置多个参数,您需要在参数中简单地按位

HANDLE hprocess = OpenProcess(PROCESS_QUERY_INFORMATION|PROCESS_TERMINATE, 0, static_cast<DWORD>(proc.th32ProcessID));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM