FormatMessage
获取GetLastError 函数返回的错误代码对应的字符串描述.
#include <Windows.h>
#include <tchar.h>
VOID PutError(DWORD error) { TCHAR* buffer; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, 0, (LPTSTR)&buffer, 0, NULL); MessageBox(NULL, buffer, NULL, 0); LocalFree(buffer); }
// 显示错误信息
PutError(GetLastError());