shell_path.hpp
Go to the documentation of this file.
1
// Copyright (c) 2006, 2007 Julio M. Merino Vidal
2
// Copyright (c) 2008 Ilya Sokolov, Boris Schaeling
3
// Copyright (c) 2009 Boris Schaeling
4
// Copyright (c) 2010 Felipe Tanus, Boris Schaeling
5
// Copyright (c) 2011, 2012 Jeff Flinn, Boris Schaeling
6
//
7
// Distributed under the Boost Software License, Version 1.0. (See accompanying
8
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9
10
#pragma once
11
12
#include <filesystem>
13
14
#include <
boost/process/config.hpp
>
15
#include <boost/system/error_code.hpp>
16
17
#include <Windows.h>
18
19
namespace
boost::process::windows
20
{
21
22
inline
std::filesystem::path
23
shell_path
()
24
{
25
TCHAR sysdir[MAX_PATH];
26
UINT size = ::GetSystemDirectory(sysdir,
sizeof
(sysdir));
27
if
(!size)
28
{
29
BOOST_PROCESS_THROW_LAST_SYSTEM_ERROR(
"GetSystemDirectory() failed"
);
30
}
31
std::filesystem::path p = sysdir;
32
return
p /
"cmd.exe"
;
33
}
34
35
inline
std::filesystem::path
36
shell_path
(boost::system::error_code& ec)
37
{
38
TCHAR sysdir[MAX_PATH];
39
UINT size = ::GetSystemDirectory(sysdir,
sizeof
(sysdir));
40
std::filesystem::path p;
41
if
(!size)
42
{
43
BOOST_PROCESS_RETURN_LAST_SYSTEM_ERROR(ec);
44
}
45
else
46
{
47
ec.clear();
48
p = sysdir;
49
p /=
"cmd.exe"
;
50
}
51
return
p;
52
}
53
54
}
// namespace boost::process::windows
config.hpp
Defines various macros.
boost::process::windows
Definition
child.hpp:17
boost::process::windows::shell_path
std::filesystem::path shell_path()
Definition
shell_path.hpp:23
boost
process
windows
shell_path.hpp
Generated by
1.13.2