public static extern bool CreateProcess(
     string lpApplicationName,
     string lpCommandLine,
     IntPtr lpProcessAttributes,
     IntPtr lpThreadAttributes,
     [MarshalAs(UnmanagedType.Bool)] bool bInheritHandles,
     CreateProcessFlags dwCreationFlags,
     IntPtr lpEnvironment,
     string lpCurrentDirectory,
     STARTUPINFO lpStartupInfo, // class
     PROCESS_INFORMATION lpProcessInformation // class
     );
예제 #2
0
파일: pipeline.cs 프로젝트: pusp/o2platform
        private NativeDbgProcess CreateProcessDebugWorker(string application, string commandArgs,
                                                          NativeMethods.CreateProcessFlags flags)
        {
            if (application == null)
            {
                throw new ArgumentException("can't be null", "application");
            }

            // Compensate for Win32's behavior, where arg[0] is the application name.
            if (commandArgs != null)
            {
                commandArgs = application + " " + commandArgs;
            }

            // This is using definition imports from Mdbg core, where these are classes.
            var pi = new PROCESS_INFORMATION(); // class

            var si = new STARTUPINFO(); // struct


            NativeMethods.CreateProcess(
                application,
                commandArgs,
                IntPtr.Zero, // process attributes
                IntPtr.Zero, // thread attributes
                false, // inherit handles,
                NativeMethods.CreateProcessFlags.CREATE_NEW_CONSOLE | flags,
                IntPtr.Zero, // env block
                null, // current dir
                si,
                pi);

            // We'll close these handle now. We'll get them again from the CreateProcess debug event.
            NativeMethods.CloseHandle(pi.hProcess);
            NativeMethods.CloseHandle(pi.hThread);

            return CreateNew(pi.dwProcessId);
        }