LPSTR ConvertErrorCodeToString(DWORD ErrorCode) { HLOCAL LocalAddress = NULL; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM, NULL, ErrorCode, 0, (char*)&LocalAddress, 0, NULL); return (LPSTR)LocalAddress; }
原文:http://www.cnblogs.com/ldxn/p/5449448.html