GetLastError
DWORD nErrorNo = GetLastError ( ); // 得到错误代码
LPSTR lpBuffer;
FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_IGNORE_INSERTS|FORMAT_MESSAGE_FROM_SYSTEM,NULL,
nErrorNo, // 此乃错误代码,通常在程序中可由 GetLastError()得之
LANG_NEUTRAL,
(LPTSTR) & lpBuffer,
0 ,
NULL );
CString strErrorCause = lpBuffer ? _T(lpBuffer) : _T( " Sorry, cannot find this error info. " );