Ejemplo n.º 1
0
        public static SuspendedProcess Start(string applicationPath, string commandLine = null, bool resumeOnDispose = true)
        {
            // Create the startup info and set the Size parameter to the size of the structure
            Win32StartupInfo startupInfo = new Win32StartupInfo();
            startupInfo.Size = Marshal.SizeOf(typeof(Win32StartupInfo));

            Win32ProcessInformation processInformation;

            // Attempt to create the process in a suspended state
            var didCreate = NativeMethods.CreateProcess(applicationPath,
                commandLine,
                IntPtr.Zero,    // NULL
                IntPtr.Zero,    // NULL
                false,
                Win32ProcessCreationFlags.Suspended,
                IntPtr.Zero,    // NULL
                null,
                ref startupInfo,
                out processInformation);

            // Check if the process was created
            if (!didCreate)
                throw new IOException("Unable to create process");

            return new SuspendedProcess(processInformation, resumeOnDispose);
        }
Ejemplo n.º 2
0
 public static extern bool CreateProcess(string applicationPath,
                                         string commandLine,
                                         IntPtr processSecurityAttributes,
                                         IntPtr threadSecurityAttributes,
                                         bool inheritHandles,
                                         Win32ProcessCreationFlags creationFlags,
                                         IntPtr environment,
                                         string currentDirectory,
                                         ref Win32StartupInfo startupInfo,
                                         out Win32ProcessInformation processInformation);
Ejemplo n.º 3
0
 public static extern bool CreateProcess(string applicationPath,
     string commandLine,
     IntPtr processSecurityAttributes,
     IntPtr threadSecurityAttributes,
     bool inheritHandles,
     Win32ProcessCreationFlags creationFlags,
     IntPtr environment,
     string currentDirectory,
     ref Win32StartupInfo startupInfo,
     out Win32ProcessInformation processInformation);