disperl/src/disperl.cxx
/////////////////////////////////////////////////////////////////////// 
// DisplayError
// Displays the error number and corresponding message.
/////////////////////////////////////////////////////////////////////// 
DisplayError
Displays the error number and corresponding message.
DisplayError Displays the error number and corresponding message .
void DisplayError(char *pszAPI,HANDLE hOutputFile)
   {
       LPVOID lpvMessageBuffer;
       CHAR szPrintBuffer[512];
       DWORD nCharsWritten;
       FormatMessage(
                FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
                NULL, GetLastError(),
                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                (LPTSTR)&lpvMessageBuffer, 0, NULL);
       wsprintf(szPrintBuffer,
         "ERROR: API    = %s.\n   error code = %d.\n   message    = %s.\n",
                pszAPI, GetLastError(), (char *)lpvMessageBuffer);
       WriteFile(hOutputFile,szPrintBuffer,
                     lstrlen(szPrintBuffer),&nCharsWritten,NULL);
       LocalFree(lpvMessageBuffer);
	   CloseHandle(hOutputFile);
       ExitProcess(GetLastError());
   }
void DisplayError ( char * pszAPI , HANDLE hOutputFile ) { LPVOID lpvMessageBuffer ; CHAR szPrintBuffer [ 512 ] ; DWORD nCharsWritten ; FormatMessage ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM , NULL , GetLastError ( ) , MAKELANGID ( LANG_NEUTRAL , SUBLANG_DEFAULT ) , ( LPTSTR ) & lpvMessageBuffer , 0 , NULL ) ; wsprintf ( szPrintBuffer , " \n \n \n " , pszAPI , GetLastError ( ) , ( char * ) lpvMessageBuffer ) ; WriteFile ( hOutputFile , szPrintBuffer , lstrlen ( szPrintBuffer ) , & nCharsWritten , NULL ) ; LocalFree ( lpvMessageBuffer ) ; CloseHandle ( hOutputFile ) ; ExitProcess ( GetLastError ( ) ) ; }
DisplayError
Displays the error number and corresponding message.
DisplayError Displays the error number and corresponding message .