// 显示Window标准错误信息
void ShowWindowsErrorText(HWND hWnd, DWORD 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
(LPSTR) &lpMsgBuf,
0,
NULL);
MessageBox(hWnd, (LPSTR)lpMsgBuf, NULL, MB_OK | MB_ICONERROR);
// Free the buffer.
LocalFree( lpMsgBuf );
return;
}
本文地址:http://com.8s8s.com/it/it3331.htm