| 184 | } |
| 185 | |
| 186 | inline std::string _GetErrorStr |
| 187 | ( |
| 188 | int e |
| 189 | ) |
| 190 | { |
| 191 | std::string ret; |
| 192 | #ifdef WINRT |
| 193 | LPTSTR s = (LPTSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, 512); |
| 194 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), s, 512, NULL ); |
| 195 | char buffer[1024]; |
| 196 | wcstombs(buffer, s, sizeof(buffer)); |
| 197 | HeapFree(GetProcessHeap(), 0, s); |
| 198 | ret = buffer; |
| 199 | #elif _WIN32 |
| 200 | LPTSTR s; |
| 201 | ::FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, e, 0, (LPTSTR)&s, 0, NULL); |
| 202 | if(s) |
| 203 | ret = s; |
| 204 | ::LocalFree(s); |
| 205 | #else |
| 206 | const char *s = strerror(e); |
| 207 | if(s) |
| 208 | ret = s; |
| 209 | #endif |
| 210 | return ret; |
| 211 | } |
| 212 | |
| 213 | bool InitNetwork |
| 214 | ( |
no outgoing calls
no test coverage detected