'GetlastError'에 해당되는 글 1건

320x100

[DEBUG] GetLastError를 이용해 마지막 에러 내용 보이기

Posted on 2008. 5. 29. 09:56
Filed Under Visual C++

// 마지막 에러 메시지를 디버그창에 보여준다.
DWORD CDMFCommonUtil::ShowLastError(void)
{
 LPVOID lpMsgBuf;  
 DWORD err;
 
 err = GetLastError();
 ::FormatMessage(
  FORMAT_MESSAGE_ALLOCATE_BUFFER |
  FORMAT_MESSAGE_FROM_SYSTEM |
  FORMAT_MESSAGE_IGNORE_INSERTS,
  NULL,
  err,
  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
  (LPTSTR) &lpMsgBuf,
  0,
  NULL
    );
 
 TRACE0(lpMsgBuf);
 //AfxMessageBox((LPTSTR)lpMsgBuf);
 ::LocalFree( lpMsgBuf );
 return err;
}
반응형

About

by 쑤기c

반응형