diff options
author | Sara Golemon <sara.golemon@mongodb.com> | 2017-08-28 18:09:22 -0400 |
---|---|---|
committer | Sara Golemon <sara.golemon@mongodb.com> | 2017-09-01 16:53:27 -0400 |
commit | bd153cba11ab82ffbf8d2bc0b801eb808369eb9e (patch) | |
tree | 9e0f9cca88d27190ac0ba03019fdd97fddb8b75a /src/mongo/util/winutil.h | |
parent | c30149da2ea0af52a1532017550431ac356f04f3 (diff) | |
download | mongo-bd153cba11ab82ffbf8d2bc0b801eb808369eb9e.tar.gz |
SERVER-29341 Set KeepAlive params on windows and mac
Diffstat (limited to 'src/mongo/util/winutil.h')
-rw-r--r-- | src/mongo/util/winutil.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/mongo/util/winutil.h b/src/mongo/util/winutil.h index a49fcc2f406..a9138e77113 100644 --- a/src/mongo/util/winutil.h +++ b/src/mongo/util/winutil.h @@ -33,11 +33,19 @@ #if defined(_WIN32) #include "text.h" +#include <atlbase.h> +#include <atlstr.h> +#include <boost/optional.hpp> +#include <sstream> +#include <string> #include <windows.h> +#include <mongo/base/status_with.h> + namespace mongo { +namespace windows { -inline std::string GetWinErrMsg(DWORD err) { +inline std::string GetErrMsg(DWORD err) { LPTSTR errMsg; ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, @@ -56,6 +64,23 @@ inline std::string GetWinErrMsg(DWORD err) { return output.str(); } -} + +/** + * Retrieve a DWORD value from the Local Machine Windows Registry for element: + * group\key + * e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\KeepAliveTime + * + * On success, returns: + * boost::none if the key does not exist. + * The value read from the registry. + * + * On failure, returns: + * ErrorCodes::InternalError - Unable to access the registry group. + * ErrorCodes::TypeMismatch - Key exists, but is of the wrong type. + */ +StatusWith<boost::optional<DWORD>> getDWORDRegistryKey(const CString& group, const CString& key); + +} // namespace windows +} // namespace mongo #endif |