1 // environment.hpp --------------------------------------------------------------//
3 // Copyright 2016 Klemens D. Morgenstern
5 // Distributed under the Boost Software License, Version 1.0.
6 // See http://www.boost.org/LICENSE_1_0.txt
8 #ifndef BOOST_DETAIL_WINAPI_ENVIRONMENT_HPP_
9 #define BOOST_DETAIL_WINAPI_ENVIRONMENT_HPP_
11 #include <boost/detail/winapi/basic_types.hpp>
13 #ifdef BOOST_HAS_PRAGMA_ONCE
17 #if !defined( BOOST_USE_WINDOWS_H )
19 #if !defined( BOOST_NO_ANSI_APIS )
20 BOOST_SYMBOL_IMPORT boost::detail::winapi::LPSTR_ WINAPI GetEnvironmentStringsA();
21 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI FreeEnvironmentStringsA(boost::detail::winapi::LPSTR_);
23 BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetEnvironmentVariableA(
24 boost::detail::winapi::LPCSTR_ lpName,
25 boost::detail::winapi::LPSTR_ lpBuffer,
26 boost::detail::winapi::DWORD_ nSize
29 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI SetEnvironmentVariableA(
30 boost::detail::winapi::LPCSTR_ lpName,
31 boost::detail::winapi::LPCSTR_ lpValue
33 #endif // !defined( BOOST_NO_ANSI_APIS )
35 BOOST_SYMBOL_IMPORT boost::detail::winapi::LPWSTR_ WINAPI GetEnvironmentStringsW();
36 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI FreeEnvironmentStringsW(boost::detail::winapi::LPWSTR_);
38 BOOST_SYMBOL_IMPORT boost::detail::winapi::DWORD_ WINAPI GetEnvironmentVariableW(
39 boost::detail::winapi::LPCWSTR_ lpName,
40 boost::detail::winapi::LPWSTR_ lpBuffer,
41 boost::detail::winapi::DWORD_ nSize
44 BOOST_SYMBOL_IMPORT boost::detail::winapi::BOOL_ WINAPI SetEnvironmentVariableW(
45 boost::detail::winapi::LPCWSTR_ lpName,
46 boost::detail::winapi::LPCWSTR_ lpValue
49 #endif // !defined( BOOST_USE_WINDOWS_H )
51 namespace boost { namespace detail { namespace winapi {
53 #if !defined( BOOST_NO_ANSI_APIS )
54 using ::GetEnvironmentStringsA;
55 using ::FreeEnvironmentStringsA;
56 using ::GetEnvironmentVariableA;
57 using ::SetEnvironmentVariableA;
58 #endif // !defined( BOOST_NO_ANSI_APIS )
60 using ::GetEnvironmentStringsW;
61 using ::FreeEnvironmentStringsW;
62 using ::GetEnvironmentVariableW;
63 using ::SetEnvironmentVariableW;
65 template< typename Char >
66 Char* get_environment_strings();
68 #if !defined( BOOST_NO_ANSI_APIS )
71 BOOST_FORCEINLINE char* get_environment_strings< char >()
73 return GetEnvironmentStringsA();
76 BOOST_FORCEINLINE BOOL_ free_environment_strings(boost::detail::winapi::LPSTR_ p)
78 return FreeEnvironmentStringsA(p);
81 BOOST_FORCEINLINE DWORD_ get_environment_variable(LPCSTR_ name, LPSTR_ buffer, DWORD_ size)
83 return GetEnvironmentVariableA(name, buffer, size);
86 BOOST_FORCEINLINE BOOL_ set_environment_variable(LPCSTR_ name, LPCSTR_ value)
88 return SetEnvironmentVariableA(name, value);
91 #endif // !defined( BOOST_NO_ANSI_APIS )
94 BOOST_FORCEINLINE wchar_t* get_environment_strings< wchar_t >()
96 return GetEnvironmentStringsW();
99 BOOST_FORCEINLINE BOOL_ free_environment_strings(boost::detail::winapi::LPWSTR_ p)
101 return FreeEnvironmentStringsW(p);
104 BOOST_FORCEINLINE DWORD_ get_environment_variable(LPCWSTR_ name, LPWSTR_ buffer, DWORD_ size)
106 return GetEnvironmentVariableW(name, buffer, size);
109 BOOST_FORCEINLINE BOOL_ set_environment_variable(LPCWSTR_ name, LPCWSTR_ value)
111 return SetEnvironmentVariableW(name, value);
114 } // namespace winapi
115 } // namespace detail
118 #endif // BOOST_DETAIL_WINAPI_ENVIRONMENT_HPP_