Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
1017 B

  1. // FormatMessage.cpp: implementation of the CFormatMessage class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include <windows.h>
  5. #include <tchar.h>
  6. #include "FormatMessage.h"
  7. //////////////////////////////////////////////////////////////////////
  8. // Construction/Destruction
  9. //////////////////////////////////////////////////////////////////////
  10. CFormatMessage::CFormatMessage( long lError )
  11. {
  12. if ( !FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, lError, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), reinterpret_cast<LPWSTR>( &m_psFormattedMessage ), 0, NULL ))
  13. {
  14. m_psFormattedMessage = NULL;
  15. _sntprintf( m_sBuffer, sizeof(m_sBuffer)/sizeof(TCHAR), _T("%x" ), lError );
  16. m_sBuffer[sizeof(m_sBuffer)/sizeof(TCHAR)-1] = 0;
  17. }
  18. }
  19. CFormatMessage::~CFormatMessage()
  20. {
  21. if ( NULL != m_psFormattedMessage )
  22. LocalFree( m_psFormattedMessage );
  23. }