00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00019 #ifndef BOOST_PROCESS_WIN32_OPERATIONS_HPP
00020 #define BOOST_PROCESS_WIN32_OPERATIONS_HPP
00021
00022 #include <boost/process/win32_child.hpp>
00023 #include <boost/process/detail/file_handle.hpp>
00024 #include <boost/process/detail/stream_info.hpp>
00025 #include <boost/process/detail/win32_ops.hpp>
00026 #include <windows.h>
00027
00028 namespace boost {
00029 namespace process {
00030
00041 template <class Executable, class Arguments, class Win32_Context>
00042 inline win32_child win32_launch(const Executable &exe, const Arguments &args, const Win32_Context &ctx)
00043 {
00044 detail::file_handle fhstdin, fhstdout, fhstderr;
00045
00046 detail::stream_info behin = detail::stream_info(ctx.stdin_behavior, false);
00047 if (behin.type_ == detail::stream_info::use_pipe)
00048 fhstdin = behin.pipe_->wend();
00049 detail::stream_info behout = detail::stream_info(ctx.stdout_behavior, true);
00050 if (behout.type_ == detail::stream_info::use_pipe)
00051 fhstdout = behout.pipe_->rend();
00052 detail::stream_info beherr = detail::stream_info(ctx.stderr_behavior, true);
00053 if (beherr.type_ == detail::stream_info::use_pipe)
00054 fhstderr = beherr.pipe_->rend();
00055
00056 detail::win32_setup s;
00057 s.work_directory = ctx.work_directory;
00058
00059 STARTUPINFOA si;
00060 if (!ctx.startupinfo)
00061 {
00062 ::ZeroMemory(&si, sizeof(si));
00063 si.cb = sizeof(si);
00064 s.startupinfo = &si;
00065 }
00066 else
00067 s.startupinfo = ctx.startupinfo;
00068
00069 PROCESS_INFORMATION pi = detail::win32_start(exe, args, ctx.environment, behin, behout, beherr, s);
00070
00071 return win32_child(pi, fhstdin, fhstdout, fhstderr);
00072 }
00073
00074 }
00075 }
00076
00077 #endif