GetLastError的学习

 dwError = GetLastError();

HLOCAL hlocal = NULL;  

   //Get the error code's textual description
   BOOL fOk = FormatMessage(
      FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
      NULL, dwError, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US),
      (PTSTR)&hlocal, 0, NULL);
    if (hlocal != NULL)
   {
       AfxMessageBox( (PCTSTR)LocalLock(hlocal));
      LocalFree(hlocal);
   }
   else 
        AfxMessageBox(("Error number not found."));

posted on 2013-09-25 16:11  bamboo_lady  阅读(127)  评论(0编辑  收藏  举报

导航