| 108 | } |
| 109 | |
| 110 | std::wstring GetLastErrorMessage() { |
| 111 | DWORD errorCode = GetLastError(); |
| 112 | LPWSTR errorMessage = nullptr; |
| 113 | |
| 114 | FormatMessageW( |
| 115 | FORMAT_MESSAGE_ALLOCATE_BUFFER | |
| 116 | FORMAT_MESSAGE_FROM_SYSTEM | |
| 117 | FORMAT_MESSAGE_IGNORE_INSERTS, |
| 118 | nullptr, errorCode, 0, |
| 119 | reinterpret_cast<LPWSTR>(&errorMessage), 0, nullptr); |
| 120 | |
| 121 | if (errorMessage != nullptr) { |
| 122 | std::wstring errorMsg(errorMessage); |
| 123 | LocalFree(errorMessage); |
| 124 | return errorMsg; |
| 125 | } |
| 126 | else { |
| 127 | return L"Failed to retrieve error message."; |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | template<typename StringType, size_t N> |
| 132 | StringType unASCIIme(const int(&ascii_values)[N]) { |
no outgoing calls
no test coverage detected