Windows核心编程之 1 错误处理



HLOCAL hlocal = NULL;   // Buffer that gets the error message string


 DWORD systemLocale = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL);


      // Get the error code's textual description
      BOOL fOk = FormatMessage(
         FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
         FORMAT_MESSAGE_ALLOCATE_BUFFER, 
         NULL, dwError, systemLocale, 
         (PTSTR) &hlocal, 0, NULL);

//输出错误

OutputDebugString((PTSTR)&hlocal);


         LocalFree(hlocal);

你可能感兴趣的:(windows,windows,核心编程)