diff --git a/include/boost/interprocess/detail/win32_api.hpp b/include/boost/interprocess/detail/win32_api.hpp index b924341c..65ca9f4b 100644 --- a/include/boost/interprocess/detail/win32_api.hpp +++ b/include/boost/interprocess/detail/win32_api.hpp @@ -2147,11 +2147,7 @@ inline bool get_wmi_class_attribute( std::wstring& strValue, const wchar_t *wmi_ return bRet; } -#ifdef BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME - -//Obtains the bootup time from WMI LastBootUpTime. -//This time seems to change with hibernation and clock synchronization so avoid it. -inline bool get_last_bootup_time( std::wstring& strValue ) +inline bool get_wmi_last_bootup_time( std::wstring& strValue) { bool ret = get_wmi_class_attribute(strValue, L"Win32_OperatingSystem", L"LastBootUpTime"); std::size_t timezone = strValue.find(L'+'); @@ -2162,13 +2158,13 @@ inline bool get_last_bootup_time( std::wstring& strValue ) if(timezone != std::wstring::npos){ strValue.erase(timezone); } - return ret; + return ret; } -inline bool get_last_bootup_time( std::string& str ) +inline bool get_wmi_last_bootup_time( std::string& str ) { std::wstring wstr; - bool ret = get_last_bootup_time(wstr); + bool ret = get_wmi_last_bootup_time(wstr); str.resize(wstr.size()); for(std::size_t i = 0, max = str.size(); i != max; ++i){ str[i] = '0' + (wstr[i]-L'0'); @@ -2176,6 +2172,20 @@ inline bool get_last_bootup_time( std::string& str ) return ret; } +#ifdef BOOST_INTERPROCESS_BOOTSTAMP_IS_LASTBOOTUPTIME + +//Obtains the bootup time from WMI LastBootUpTime. +//This time seems to change with hibernation and clock synchronization so avoid it. +inline bool get_last_bootup_time( std::wstring& strValue ) +{ + return get_wmi_last_bootup_time(strValue); +} + +inline bool get_last_bootup_time( std::string& str ) +{ + return get_wmi_last_bootup_time(str); +} + #else // Loop through the buffer and obtain the contents of the @@ -2252,7 +2262,7 @@ inline bool get_last_bootup_time(std::string &stamp) } } else{ //Not found or EOF - return false; + return get_wmi_last_bootup_time(stamp); } } else