LPVOID lpMsgBuf;
DWORD dwError = GetLastError();
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
dwError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
::OutputDebugString((LPCTSTR)lpMsgBuf);
LocalFree(lpMsgBuf);
[참고 : Retrieving the Last-Error Code]