5#include <boost/locale.hpp>
26 inline std::wstring to_wstring(
const std::string& u8) {
27 return boost::locale::conv::to_utf<wchar_t>(u8,
"UTF-8");
39 inline int start(
const std::string app, std::string arg =
"",
const bool wait =
false,
const std::string& cd =
"") {
40 STARTUPINFO si = {
sizeof(si) };
41 PROCESS_INFORMATION pi;
44 to_wstring(app).c_str(),
45 to_wstring(app +
" " + arg).data(),
50 (cd.empty()? NULL: to_wstring(cd).c_str()),
54 WaitForSingleObject(pi.hProcess, INFINITE);
56 if (GetExitCodeProcess(pi.hProcess, &exitCode)) {
58 }
else throw std::runtime_error(
"yy981/proc.h::start(): 返り値取得失敗");
60 CloseHandle(pi.hProcess);
61 CloseHandle(pi.hThread);
62 }
else throw std::runtime_error(
"yy981/proc.h::start(): 起動失敗 | GetLastError()=" + std::to_string(GetLastError()));
76 inline int start(
const std::string app, std::string arg =
"",
const bool wait =
false,
const std::string& cd =
"") {
77 STARTUPINFO si = {
sizeof(si) };
78 PROCESS_INFORMATION pi;
82 (app +
" " + arg).data(),
87 (cd.empty()? NULL: cd.c_str()),
91 WaitForSingleObject(pi.hProcess, INFINITE);
93 if (GetExitCodeProcess(pi.hProcess, &exitCode)) {
95 }
else throw std::runtime_error(
"yy981/proc.h::start(): 返り値取得失敗");
97 CloseHandle(pi.hProcess);
98 CloseHandle(pi.hThread);
99 }
else throw std::runtime_error(
"yy981/proc.h::start(): 起動失敗 | GetLastError()=" + std::to_string(GetLastError()));
int start(const std::string app, std::string arg="", const bool wait=false, const std::string &cd="")
外部アプリケーションを起動する(ANSI ビルド版)