Beispiel #1
0
        internal static IntPtr LaunchProcessSuspended(string processPath, string commandLine, out uint PID, out string actualProcessPath)
        {
            var fullProcessPath = GetFullProcessPath(processPath);

            STARTUPINFO         si = new STARTUPINFO();
            PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
            bool success           = Win32Interop.CreateProcess(fullProcessPath, commandLine,
                                                                IntPtr.Zero, IntPtr.Zero, false, ProcessCreationFlags.CREATE_SUSPENDED | ProcessCreationFlags.CREATE_NEW_CONSOLE,
                                                                IntPtr.Zero, null, ref si, out pi);
            var threadHandle = pi.hThread;

            PID = pi.dwProcessId;

            actualProcessPath = fullProcessPath;

            return(success ? threadHandle : IntPtr.Zero);
        }