Ejemplo n.º 1
0
        private static unsafe NativeProcess CreateProcessInternal(string applicationName, string commandLine, CreateProcessFlags flags, StartupInfoW startupInfo, string currentDirectory, out NativeThread firstThread)
        {
            ProcessInformation processInfo;

            bool success = CreateProcessW(applicationName, commandLine, null, null, false, (UInt32)flags, null, currentDirectory, &startupInfo, &processInfo);

            if (!success)
            {
                throw new Win32Exception();
            }

            firstThread = new NativeThread(new SafeThreadHandle(processInfo.hThread));
            return(new NativeProcess(new SafeProcessHandle(processInfo.hProcess)));
        }
Ejemplo n.º 2
0
        public static NativeProcess CreateProcess(string applicationName, string commandLine, CreateProcessFlags flags, StartupInfoFlags flags2, ProcThreadAttributeList atts, string currentDirectory, out NativeThread firstThread)
        {
            StartupInfoW startupInfo = new StartupInfoW(flags2);

            return(CreateProcess(applicationName, commandLine, flags, startupInfo, atts, currentDirectory, out firstThread));
        }
Ejemplo n.º 3
0
        public static NativeProcess CreateProcess(string applicationName, string commandLine, CreateProcessFlags flags, StartupInfoW startupInfo, ProcThreadAttributeList atts, string currentDirectory, out NativeThread firstThread)
        {
            if ((flags & ~SupportedCreateProcessFlags) != 0)
            {
                throw new ArgumentException("Unsupported CreateProcessFlags given!");
            }
            if ((startupInfo.dwFlags & ~SupportedStartupInfoFlags) != 0)
            {
                throw new ArgumentException("Unsupported StartupInfoFlags given");
            }
            if (atts.IsDisposed)
            {
                throw new ObjectDisposedException("Atts");
            }

            StartupInfoExW startupInfoEx = new StartupInfoExW(startupInfo, atts);

            flags |= CreateProcessFlags.ExtendedStartupInfoPresent;

            return(CreateProcessInternal(applicationName, commandLine, flags, startupInfoEx, currentDirectory, out firstThread));
        }
Ejemplo n.º 4
0
        public static NativeProcess CreateProcess(string applicationName, string commandLine, CreateProcessFlags flags, StartupInfoW startupInfo, string currentDirectory, out NativeThread firstThread)
        {
            if ((flags & ~SupportedCreateProcessFlags) != 0)
            {
                throw new ArgumentException("Unsupported CreateProcessFlags given!");
            }
            if ((startupInfo.dwFlags & ~SupportedStartupInfoFlags) != 0)
            {
                throw new ArgumentException("Unsupported StartupInfoFlags given");
            }

            return(CreateProcessInternal(applicationName, commandLine, flags, startupInfo, currentDirectory, out firstThread));
        }