| 11 | } |
| 12 | |
| 13 | std::wstring Helpers::GetUserInput(DWORD promptMsg, DWORD maxCharacters) |
| 14 | { |
| 15 | Helpers::PrintMessage(promptMsg); |
| 16 | size_t bufferSize = maxCharacters + 1; |
| 17 | std::unique_ptr<wchar_t[]> inputBuffer(new wchar_t[bufferSize]); |
| 18 | std::wstring input; |
| 19 | if (wscanf_s(L"%s", inputBuffer.get(), (unsigned int)bufferSize) == 1) { |
| 20 | input = inputBuffer.get(); |
| 21 | } |
| 22 | |
| 23 | // Throw away any additional chracters that did not fit in the buffer. |
| 24 | wchar_t wch; |
| 25 | do { |
| 26 | wch = getwchar(); |
| 27 | |
| 28 | } while ((wch != L'\n') && (wch != WEOF)); |
| 29 | |
| 30 | return input; |
| 31 | } |
| 32 | |
| 33 | void Helpers::PrintErrorMessage(HRESULT error) |
| 34 | { |
nothing calls this directly
no outgoing calls
no test coverage detected