GetLastError获得错误信息

 

 
void ShowError(long nErrorCode)
{
LPVOID lpMsgBuf;
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER | 
FORMAT_MESSAGE_FROM_SYSTEM | 
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
wchar_t errorCode[20];
_itow_s(nErrorCode,errorCode,10);
 
MessageBox(NULL,(LPTSTR)lpMsgBuf,errorCode,0);
LocalFree(lpMsgBuf); // free the buffer.
}
 

你可能感兴趣的:(职场,休闲,GetLastError)