FormatMessage
来源:互联网 发布:sql删除字段的数据 编辑:程序博客网 时间:2024/05/17 23:08
/** * 函数:XFormatMessage * 描述:格式化GetLastError信息 * 参数: *lpszFunc 调用函数名字 *lpszMsg 输出错误信息 *nMsgBuff 缓冲区长度 * 返回:错误码 */DWORD XFormatMessage(LPCTSTR lpszFunc, LPTSTR lpszMsg, int nMsgBuff){ LPVOID lpMsgBuf; DWORD dwError = GetLastError(); FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf, 0, NULL ); wnsprintf(lpszMsg, nMsgBuff, _T("%s 出错信息 (出错码=%d): %s"), lpszFunc, dwError, lpMsgBuf); LocalFree(lpMsgBuf); OutputDebugString(lpszMsg);return dwError;}