GetLastError() 显示错误信息

LPVOID lpMsgBuf; 
FormatMessage( 
	FORMAT_MESSAGE_ALLOCATE_BUFFER | 
	FORMAT_MESSAGE_FROM_SYSTEM | 
	FORMAT_MESSAGE_IGNORE_INSERTS, 
	NULL, 
	GetLastError(), 
	MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
	(LPTSTR) &lpMsgBuf, 
	0, 
	NULL 
	); 
CString errstr;
errstr.Format("错误信息:%s",(LPCTSTR)lpMsgBuf);
MessageBox(errstr /* (LPCTSTR)lpMsgBuf*/); 
LocalFree( lpMsgBuf );

你可能感兴趣的:(VC/MFC)