Пример #1
0
        public static IntPtr SpawnNewProcess(string processName)
        {
            STRUCTS.STARTUPINFO         si = new STRUCTS.STARTUPINFO();
            STRUCTS.PROCESS_INFORMATION pi = new STRUCTS.PROCESS_INFORMATION();
            bool success = IMPORTS.CreateProcessA(null, processName,
                                                  IntPtr.Zero, IntPtr.Zero, false,
                                                  STRUCTS.ProcessCreationFlags.CREATE_NO_WINDOW,
                                                  IntPtr.Zero, null, ref si, out pi);

            Console.WriteLine("Process {0} Created! \n PID: {1}", processName, pi.dwProcessId);
            return(pi.hProcess);
        }
Пример #2
0
 public static extern bool CreateProcessA(string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, STRUCTS.ProcessCreationFlags dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, ref STRUCTS.STARTUPINFO lpStartupInfo, out STRUCTS.PROCESS_INFORMATION lpProcessInformation);