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.

85 lines
2.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1996, Microsoft Corporation.
  4. //
  5. // File: qlibutil.hxx
  6. //
  7. // Contents: Utility macros and functions for querylib.lib
  8. //
  9. // History: 17-May-94 t-jeffc Created.
  10. // 02-Mar-95 t-colinb Added INLINE_UNWIND to the
  11. // smart pointer declarations
  12. // 01-Mar-96 dlee converted to templates
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. // util.cxx
  17. FILE * OpenFileFromPath( WCHAR const * wcsFile );
  18. enum
  19. {
  20. eDontCare = 0,
  21. eMostDetailed,
  22. eMostGeneric,
  23. eMostDetailedOleDBError,
  24. eMostGenericOleDBError,
  25. eMostDetailedCIError,
  26. eMostGenericCIError
  27. };
  28. SCODE GetOleDBErrorInfo(IUnknown *pErrSrc,
  29. REFIID riid,
  30. LCID lcid,
  31. unsigned eDesiredDetail,
  32. ERRORINFO *pErrorInfo,
  33. IErrorInfo **ppIErrorInfo);
  34. //+---------------------------------------------------------------------------
  35. //
  36. // Class: CSFile
  37. //
  38. // Purpose: Lightweight class to wrap a FILE * so the file will
  39. // always be closed, even if an exception is thrown.
  40. //
  41. // Notes: Operators -> and FILE * are overloaded so a CSFile may
  42. // be treated like a FILE * in the CRT functions.
  43. //
  44. // History: 17-May-94 t-jeffc Created.
  45. //
  46. //----------------------------------------------------------------------------
  47. class CSFile : INHERIT_UNWIND
  48. {
  49. INLINE_UNWIND( CSFile );
  50. public:
  51. CSFile( FILE * pfile )
  52. {
  53. _pfile = pfile;
  54. END_CONSTRUCTION( CSFile );
  55. }
  56. ~CSFile()
  57. {
  58. if( _pfile != NULL )
  59. fclose( _pfile );
  60. }
  61. FILE * Acquire()
  62. {
  63. FILE * pfileTmp = _pfile;
  64. _pfile = 0;
  65. return pfileTmp;
  66. }
  67. FILE * operator->() { return( _pfile ); }
  68. operator FILE * () { return( _pfile ); }
  69. private:
  70. FILE * _pfile;
  71. };