这个代码可以获得GetLastError所对应的字符串
#include <windows.h>#include <stdio.h>
#include <tchar.h>
int main()
{
DWORD nErrorNo; // 错误代码
printf("请出入一个数字(错误号):\n");
scanf("%u", &nErrorNo);
LPSTR lpBuffer;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
nErrorNo,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) & lpBuffer,
0,
NULL);
printf("返回信息: %s\n", lpBuffer);
return 0;
}