コード例 #1
0
ファイル: NativeProcess.cs プロジェクト: henke37/debugHelp
        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));
        }
コード例 #2
0
ファイル: NativeProcess.cs プロジェクト: henke37/debugHelp
        private static unsafe NativeProcess CreateProcessInternal(string applicationName, string commandLine, CreateProcessFlags flags, StartupInfoExW startupInfo, string currentDirectory, out NativeThread firstThread)
        {
            ProcessInformation processInfo;

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

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

            firstThread = new NativeThread(new SafeThreadHandle(processInfo.hThread));
            return(new NativeProcess(new SafeProcessHandle(processInfo.hProcess)));
        }