Pass Multiple Process Creation flags to CreateProcess

Deadly 提交于 2020-01-06 04:09:06

问题


I am using CreateProcess and I would like to pass CREATE_SUSPENDED and CREATE_NO_WINDOW as the Process Creation Flags.

This is my pinvoke signature:

[DllImport("kernel32.dll", SetLastError = true)]
private static extern Boolean CreateProcess(String lpApplicationName, String lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes,
            Boolean bInheritHandles, UInt32 dwCreationFlags, IntPtr lpEnvironment, String lpCurrentDirectory, Byte[] lpStartupInfo,
            out PROCESS_INFORMATION lpProcessInfo);

The question is: How to pass multiple flags?


回答1:


Since all the flags have a single 1 in a single binary position, you can combine them together by OR-ing or by adding them together:

CREATE_SUSPENDED | CREATE_NO_WINDOW

Here is how it works:

CREATE_NO_WINDOW  is 0x08000000
CREATE_SUSPENDED  is 0x00000004

The result of OR-ing them together is 0x08000004.



来源:https://stackoverflow.com/questions/22438497/pass-multiple-process-creation-flags-to-createprocess

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!