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.

168 lines
4.9 KiB

  1. /*******************************************************************************
  2. *
  3. * (C) COPYRIGHT MICROSOFT CORPORATION, 2000
  4. *
  5. * TITLE: DUMPPROP.H
  6. *
  7. * VERSION: 1.0
  8. *
  9. * AUTHOR: ShaunIv
  10. *
  11. * DATE: 9/25/2000
  12. *
  13. * DESCRIPTION: Display the properties associated with a IWiaItem, either to the
  14. * debugger, or to a log file.
  15. *
  16. *******************************************************************************/
  17. #ifndef __DUMPPROP_H_INCLUDED
  18. #define __DUMPPROP_H_INCLUDED
  19. #include <simstr.h>
  20. #include <wia.h>
  21. #include <wiadebug.h>
  22. class CWiaDebugDump
  23. {
  24. private:
  25. //
  26. // No implementation
  27. //
  28. CWiaDebugDump( const CWiaDebugDump & );
  29. CWiaDebugDump &operator=( const CWiaDebugDump & );
  30. public:
  31. //
  32. // Static helper functions
  33. //
  34. static CSimpleString GetPropVariantTypeString( VARTYPE vt );
  35. static CSimpleString GetPrintableValue( PROPVARIANT &PropVariant );
  36. static CSimpleString GetPrintableValue( VARIANT &Variant );
  37. static CSimpleString GetPrintableName( const STATPROPSTG &StatPropStg );
  38. static CSimpleString GetPrintableAccessFlags( ULONG nAccessFlags );
  39. static CSimpleString GetPrintableLegalValues( ULONG nAccessFlags, const PROPVARIANT &PropVariantAttributes );
  40. static CSimpleString GetWiaItemTypeFlags( IUnknown *pUnknown );
  41. static CSimpleString GetStringFromGuid( const GUID &guid );
  42. static CSimpleString GetTymedString( LONG tymed );
  43. virtual void Print( LPCTSTR pszString );
  44. protected:
  45. void PrintAndDestroyWiaDevCap( WIA_DEV_CAP &WiaDevCap, LPCTSTR pszType );
  46. public:
  47. //
  48. // Constructor and destructor
  49. //
  50. CWiaDebugDump(void);
  51. virtual ~CWiaDebugDump(void);
  52. //
  53. // Helpers
  54. //
  55. void DumpFormatInfo( IUnknown *pUnknown );
  56. void DumpCaps( IUnknown *pUnknown );
  57. void DumpEvents( IUnknown *pUnknown );
  58. virtual bool OK(void) { return true; }
  59. //
  60. // These are the most generally useful functions
  61. //
  62. void DumpWiaPropertyStorage( IUnknown *pUnknown );
  63. void DumpWiaItem( IUnknown *pUnknown );
  64. void DumpRecursive( IUnknown *pUnknown );
  65. };
  66. class CWiaDebugDumpToFile : public CWiaDebugDump
  67. {
  68. private:
  69. HANDLE m_hFile;
  70. private:
  71. CWiaDebugDumpToFile(void);
  72. CWiaDebugDumpToFile( const CWiaDebugDumpToFile & );
  73. CWiaDebugDumpToFile &operator=( const CWiaDebugDumpToFile & );
  74. public:
  75. //
  76. // Constructor and destructor
  77. //
  78. CWiaDebugDumpToFile( LPCTSTR pszFilename, bool bOverwrite );
  79. virtual ~CWiaDebugDumpToFile(void);
  80. virtual bool OK(void) { return (m_hFile != INVALID_HANDLE_VALUE); }
  81. virtual void Print( LPCTSTR pszString );
  82. };
  83. class CWiaDebugDumpToFileHandle : public CWiaDebugDump
  84. {
  85. private:
  86. HANDLE m_hFile;
  87. private:
  88. CWiaDebugDumpToFileHandle(void);
  89. CWiaDebugDumpToFileHandle( const CWiaDebugDumpToFileHandle & );
  90. CWiaDebugDumpToFileHandle &operator=( const CWiaDebugDumpToFileHandle & );
  91. public:
  92. //
  93. // Constructor and destructor
  94. //
  95. CWiaDebugDumpToFileHandle( HANDLE hFile );
  96. virtual ~CWiaDebugDumpToFileHandle(void);
  97. virtual bool OK(void) { return (m_hFile != INVALID_HANDLE_VALUE); }
  98. virtual void Print( LPCTSTR pszString );
  99. };
  100. //
  101. // This small helper function checks a registry entry, and saves the item or tree to the log file stored in that entry. If
  102. // one is not stored in that registry entry, nothing will be saved
  103. //
  104. inline void SaveItemTreeLog( HKEY hKey, LPCTSTR pszRegKey, LPCTSTR pszRegValue, bool bOverwrite, IWiaItem *pWiaItem, bool bRecurse )
  105. {
  106. CSimpleString strFilename = CSimpleReg(hKey,pszRegKey,false,KEY_READ).Query(pszRegValue,TEXT(""));
  107. if (strFilename.Length())
  108. {
  109. if (bRecurse)
  110. {
  111. CWiaDebugDumpToFile(strFilename,bOverwrite).DumpRecursive(pWiaItem);
  112. }
  113. else
  114. {
  115. CWiaDebugDumpToFile(strFilename,bOverwrite).DumpWiaItem(pWiaItem);
  116. }
  117. }
  118. }
  119. //
  120. // Debug-only macros
  121. //
  122. #if defined(DBG) || defined(DEBUG) || defined(_DEBUG)
  123. //
  124. // Save the whole tree to a log file, from this item down
  125. //
  126. #define WIA_SAVEITEMTREELOG(hKey,pszRegKey,pszRegValue,bOverwrite,pWiaItem) SaveItemTreeLog( hKey, pszRegKey, pszRegValue, bOverwrite, pWiaItem, true )
  127. //
  128. // Save this item to a log file
  129. //
  130. #define WIA_SAVEITEMLOG(hKey,pszRegKey,pszRegValue,bOverwrite,pWiaItem) SaveItemTreeLog( hKey, pszRegKey, pszRegValue, bOverwrite, pWiaItem, false )
  131. //
  132. // Print this item in the debugger
  133. //
  134. #define WIA_DUMPWIAITEM(pWiaItem) CWiaDebugDump().DumpWiaItem(pWiaItem);
  135. #else
  136. #define WIA_SAVEITEMTREELOG(hKey,pszRegKey,pszRegValue,bOverwrite,pWiaItem)
  137. #define WIA_SAVEITEMLOG(hKey,pszRegKey,pszRegValue,bOverwrite,pWiaItem)
  138. #define WIA_DUMPWIAITEM(pWiaItem)
  139. #endif
  140. #endif // __DUMPPROP_H_INCLUDED