void ShowError(long nErrorCode)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
wchar_t errorCode[20];
_itow_s(nErrorCode,errorCode,10);
MessageBox(NULL,(LPTSTR)lpMsgBuf,errorCode,0);
LocalFree(lpMsgBuf); // free the buffer.
}
转载于:https://blog.51cto.com/2youyou2/737456