Created
November 14, 2013 03:45
-
-
Save Aaronontheweb/7461004 to your computer and use it in GitHub Desktop.
How to format the output of Win32's GetLastError() method into a string using FormatString
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DWORD dLastError = GetLastError(); | |
LPCTSTR strErrorMessage = NULL; | |
FormatMessage( | |
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_ARGUMENT_ARRAY | FORMAT_MESSAGE_ALLOCATE_BUFFER, | |
NULL, | |
dLastError, | |
0, | |
(LPWSTR) &strErrorMessage, | |
0, | |
NULL); | |
//Prints debug output to the console | |
OutputDebugString(strErrorMessage); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-formatmessage