示例#1
0
 public static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes,
     IntPtr lpThreadAttributes, bool bInheritHandles, int dwCreationFlags, IntPtr lpEnvironment,
     string lpCurrentDirectory, ref StartUpInfo lpStartupInfo, ref ProcessInfo lpProcessInformation);
示例#2
0
        /// <summary>
        /// Creates a new process in a desktop.
        /// </summary>
        /// <param name="path">Path to application.</param>
        /// <returns>The process object for the newly created process.</returns>
        public Process CreateProcess(string path)
        {
            // make sure object isnt disposed.
            CheckDisposed();

            // make sure a desktop is open.
            if (!IsOpen)
                return null;

            // set startup parameters.
            var si = new StartUpInfo();
            si.cb = Marshal.SizeOf(si);
            si.lpDesktop = DesktopName;

            var pi = new ProcessInfo();

            // start the process.
            var result = Kernel32.CreateProcess(null, path, IntPtr.Zero, IntPtr.Zero, true, NORMAL_PRIORITY_CLASS, IntPtr.Zero, null, ref si, ref pi);

            // error?
            return !result ? null : Process.GetProcessById(pi.ProcessId);
        }
示例#3
0
 public static extern bool CreateProcess(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes,
                                         IntPtr lpThreadAttributes, bool bInheritHandles, int dwCreationFlags, IntPtr lpEnvironment,
                                         string lpCurrentDirectory, ref StartUpInfo lpStartupInfo, ref ProcessInfo lpProcessInformation);