コード例 #1
0
        private static void CreateProcess(
            string lpApplicationName,
            string lpCommandLine,
            bool bInheritHandles,
            uint dwCreationFlags,
            ref Syscalls.STARTUPINFO lpStartupInfo,
            out Syscalls.PROCESS_INFORMATION lpProcessInformation)
        {
            int retval;

            retval = Syscalls._CreateProcess(
                lpApplicationName,
                lpCommandLine,
                new IntPtr(0), new IntPtr(0),
                bInheritHandles,
                dwCreationFlags,
                new IntPtr(0), null,
                ref lpStartupInfo,
                out lpProcessInformation);

            if (retval == 0)
            {
                int errcode = Marshal.GetLastWin32Error();
                throw new Exception("Cannot create process (" + errcode + ": " + Syscalls.GetLastErrorStringMessage() + ")");
            }
        }