| 1658 | |
| 1659 | |
| 1660 | LPTSTR GetWin32ErrorText(LPTSTR aBuf, DWORD aBufSize, DWORD aError) |
| 1661 | // aBufSize is an int to preserve any negative values the caller might pass in. |
| 1662 | { |
| 1663 | if (aBufSize < 1) |
| 1664 | return aBuf; |
| 1665 | if (aBufSize == 1) |
| 1666 | { |
| 1667 | *aBuf = '\0'; |
| 1668 | return aBuf; |
| 1669 | } |
| 1670 | FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM|FORMAT_MESSAGE_IGNORE_INSERTS // Ignore inserts: https://blogs.msdn.microsoft.com/oldnewthing/20071128-00/?p=24353 |
| 1671 | , NULL, aError, 0, aBuf, (DWORD)aBufSize - 1, NULL); |
| 1672 | return aBuf; |
| 1673 | } |
| 1674 | |
| 1675 | |
| 1676 | |