| 251 | } |
| 252 | |
| 253 | std::wstring formatErrorInfo(unsigned long err) { |
| 254 | std::wostringstream out; |
| 255 | if (!err) |
| 256 | err = GetLastError(); |
| 257 | LPWSTR mBuf = NULL; |
| 258 | if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 259 | NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPWSTR)&mBuf, 0, NULL)) |
| 260 | out << "Failed to format error message, last error was: " << err; |
| 261 | else { |
| 262 | std::wstring tempOut = std::wstring(mBuf); |
| 263 | boost::trim_right(tempOut); |
| 264 | out << tempOut; |
| 265 | } |
| 266 | |
| 267 | return out.str(); |
| 268 | } |
| 269 | |
| 270 | std::wstring stateToString(const state& state) { |
| 271 | switch (state) { |