FormatMessage

时间:2021-09-26 20:19:20

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,
,
(LPTSTR)&buffer,
,
NULL);
MessageBox(NULL, buffer, NULL, );
LocalFree(buffer);
}
// 显示错误信息
PutError(GetLastError());