home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / com / allinone / collect / stdafx.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-03  |  1.2 KB  |  33 lines

  1. // This is a part of the Microsoft Foundation Classes C++ library.
  2. // Copyright (C) 1992-1995 Microsoft Corporation
  3. // All rights reserved.
  4. //
  5. // This source code is only intended as a supplement to the
  6. // Microsoft Foundation Classes Reference and related
  7. // electronic documentation provided with the library.
  8. // See these sources for detailed information regarding the
  9. // Microsoft Foundation Classes product.
  10.  
  11. // stdafx.cpp : source file that includes just the standard includes
  12. //  collect.pch will be the pre-compiled header
  13. //  stdafx.obj will contain the pre-compiled type information
  14.  
  15. #include "stdafx.h"
  16.  
  17. void dump_com_error(_com_error &e)
  18. {
  19.     _bstr_t bstrSource(e.Source());
  20.     _bstr_t bstrDescription(e.Description());
  21.     TCHAR szTemp[1024];
  22.     CString csMsg = "Oops - hit an error!\n";
  23.     wsprintf(szTemp, _T("Code = %08lx\n"), e.Error());
  24.     csMsg += szTemp;
  25.     wsprintf(szTemp, _T("Code meaning = %s\n"), e.ErrorMessage());
  26.     csMsg += szTemp;
  27.     wsprintf(szTemp, _T("Source = %s\n"), bstrSource.length() ? (LPCTSTR)bstrSource : _T("null"));
  28.     csMsg += szTemp;
  29.     wsprintf(szTemp, _T("Description = %s\n"), bstrDescription.length() ? (LPCTSTR)bstrDescription : _T("null"));
  30.     csMsg += szTemp;
  31.     AfxMessageBox(csMsg);
  32. }
  33.