// Get the error code
DWORD dwError = GetDlgItemInt(IDC_EDIT1);
HLOCAL hlocal = NULL; // Buffer that gets the error message string
// Use the default system locale since we look for Windows messages.
// Note: this MAKELANGID combination has 0 as value
DWORD systemLocale = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);
// Get the error code's textual description
BOOL fOk = FormatMessage(
FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
FORMAT_MESSAGE_ALLOCATE_BUFFER,
NULL, dwError, systemLocale,
(PTSTR) &hlocal, 0, NULL);
SetDlgItemText(IDC_TEXTOUT,(PTSTR) LocalLock(hlocal));
FormatMessage 错误消息
最新推荐文章于 2024-07-28 20:21:24 发布