compclen.h
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 7k
Category:

Windows Kernel

Development Platform:

Visual C++

  1. /*
  2. **------------------------------------------------------------------------------
  3. ** Module:  NTFS Compression Disk Cleanup cleaner
  4. ** File:    cclean.h
  5. **
  6. ** Purpose: Defines the 'Compression cleaner' for the IEmptyVolumeCache2
  7. **          interface
  8. ** Notes:
  9. ** Mod Log: Created by Jason Cobb (2/97)
  10. **          Adapted for NTFS compression clean by DSchott (6/98)
  11. **
  12. ** Copyright (c)1997-1998 Microsoft Corporation. All Rights Reserved.
  13. **------------------------------------------------------------------------------
  14. */
  15. #ifndef COMPCLEN_H
  16. #define COMPCLEN_H
  17. #ifndef COMMON_H
  18.     #include "common.h"
  19. #endif
  20. #ifndef WINNT
  21. //
  22. // Stolen from DEVIOCTL.H
  23. //
  24. #ifndef CTL_CODE
  25.    #define CTL_CODE( DeviceType, Function, Method, Access ) ( 
  26.             ((DeviceType) << 16)  | ((Access) << 14) | ((Function) << 2) | (Method) 
  27.            )
  28. #endif
  29. #ifndef METHOD_BUFFERED
  30.     #define METHOD_BUFFERED 0
  31. #endif
  32. #ifndef FILE_DEVICE_FILE_SYSTEM
  33.    #define FILE_DEVICE_FILE_SYSTEM 0x00000009
  34. #endif
  35. // END Stolen from DEVIOCTL.H
  36. //
  37. // Stolen from NTIOAPI.H
  38. //
  39. #ifndef FILE_ATTRIBUTE_OFFLINE
  40.    #define FILE_ATTRIBUTE_OFFLINE 0x00001000  // winnt
  41. #endif
  42. #ifndef FSCTL_SET_COMPRESSION
  43.    #define FSCTL_SET_COMPRESSION CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 16, METHOD_BUFFERED, FILE_READ_DATA | FILE_WRITE_DATA)
  44. #endif
  45. // END Stolen from NTIOAPI.H
  46. #endif // !winnt
  47. /*
  48. **------------------------------------------------------------------------------
  49. ** Project include files 
  50. **------------------------------------------------------------------------------
  51. */
  52. /*
  53. **------------------------------------------------------------------------------
  54. ** Global Defines 
  55. **------------------------------------------------------------------------------
  56. */
  57. #define COMPCLN_REGPATH TEXT("SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Compress old files")
  58. #define MAX_DAYS 500           // Settings dialog spin control max
  59. #define MIN_DAYS 1             // Settings dialog spin control min
  60. #define DEFAULT_DAYS 50        // Default #days if no setting in registry
  61. /*
  62. **------------------------------------------------------------------------------
  63. ** Global function prototypes
  64. **------------------------------------------------------------------------------
  65. */
  66. //
  67. // Already defined in common.h
  68. //
  69. // Dll Object count methods
  70. //UINT getDllObjectCount (void);
  71. //
  72. // Dll Lock count methods
  73. //UINT getDllLockCount (void);
  74. /*
  75. **------------------------------------------------------------------------------
  76. ** Class Declarations
  77. **------------------------------------------------------------------------------
  78. */
  79. /*
  80. **------------------------------------------------------------------------------
  81. ** Class:   CCompCleanerClassFactory
  82. ** Purpose: Manufactures instances of our CCompCleaner object
  83. ** Notes:   
  84. ** Mod Log: Created by Jason Cobb (2/97)
  85. **          Adapted for NTFS compression cleaner by DSchott (6/98)
  86. **------------------------------------------------------------------------------
  87. */ 
  88. class CCompCleanerClassFactory : public IClassFactory
  89. {
  90. private:
  91. protected:
  92.     //
  93.     // Data
  94.     //
  95.     ULONG   m_cRef;     // Reference count
  96. public:
  97.     //
  98.     // Constructors
  99.     //
  100.     CCompCleanerClassFactory();
  101.     ~CCompCleanerClassFactory();
  102.   
  103.         //
  104.     // IUnknown interface members
  105.     //
  106.         STDMETHODIMP            QueryInterface(REFIID, LPVOID FAR *);
  107.         STDMETHODIMP_(ULONG)    AddRef();
  108.         STDMETHODIMP_(ULONG)    Release();
  109.     //   
  110.     // IClassFactory interface members
  111.         //
  112.         STDMETHODIMP            CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
  113.         STDMETHODIMP            LockServer(BOOL);
  114. };
  115. typedef CCompCleanerClassFactory *LPCCOMPCLEANERCLASSFACTORY;
  116. /*
  117. **------------------------------------------------------------------------------
  118. ** Class:   CCompCleaner
  119. ** Purpose: This is the actual Compression Cleaner Class
  120. ** Notes:   
  121. ** Mod Log: Created by Jason Cobb (2/97)
  122. **          Adapted for NTFS compression cleaner by DSchott (6/98)
  123. **------------------------------------------------------------------------------
  124. */ 
  125. class CCompCleaner : public IEmptyVolumeCache2
  126. {
  127. private:
  128. protected:
  129.     //
  130.     // Data
  131.     //
  132.     ULONG               m_cRef;                 // reference count
  133.     LPDATAOBJECT        m_lpdObject;            // Last Data object
  134.     ULARGE_INTEGER      cbSpaceUsed;
  135.     ULARGE_INTEGER      cbSpaceFreed;
  136.     FILETIME            ftMinLastAccessTime;
  137.     DWORD               dwDaysForCurrentLAD;
  138.     DWORD               dwDaysForCurrentList;
  139.     TCHAR               szVolume[MAX_PATH];
  140.     TCHAR               szFolder[MAX_PATH];
  141.     TCHAR               filelist[MAX_PATH];
  142.     BOOL                bPurged;                // TRUE if Purge() method was run
  143.     BOOL                bSettingsMode;          // TRUE if currently in settings mode
  144.     PCLEANFILESTRUCT    head;                   // head of the linked list of files
  145.     BOOL WalkForUsedSpace(PTCHAR lpPath, IEmptyVolumeCacheCallBack *picb);
  146.     BOOL AddFileToList(PTCHAR lpFile, ULARGE_INTEGER filesize, BOOL bDirectory);
  147.     void PurgeFiles(IEmptyVolumeCacheCallBack *picb, BOOL bDoDirectories);
  148.     void FreeList(PCLEANFILESTRUCT pCleanFile);
  149.     void BuildList(IEmptyVolumeCacheCallBack *picb);
  150.     void CalcLADFileTime();
  151.     BOOL bLastAccessisOK(FILETIME ftFileLastAccess);
  152. public:
  153.     //
  154.     // Constructors
  155.     //
  156.     CCompCleaner (void);
  157.     ~CCompCleaner (void);
  158.     //
  159.     // IUnknown interface members
  160.     //
  161.     STDMETHODIMP            QueryInterface (REFIID, LPVOID FAR *);
  162.     STDMETHODIMP_(ULONG)    AddRef (void);
  163.     STDMETHODIMP_(ULONG)    Release (void);
  164.     
  165.     //
  166.     // IEmptyVolumeCache2 interface members
  167.     //
  168.     STDMETHODIMP    Initialize(
  169.                 HKEY hRegKey,
  170.                 LPCWSTR pszVolume,
  171.                 LPWSTR *ppszDisplayName,
  172.                 LPWSTR *ppszDescription,
  173.                 DWORD *pdwFlags
  174.                 );
  175.     STDMETHODIMP    GetSpaceUsed(
  176.                 DWORDLONG *pdwSpaceUsed,
  177.                 IEmptyVolumeCacheCallBack *picb
  178.                 );
  179.                 
  180.     STDMETHODIMP    Purge(
  181.                 DWORDLONG dwSpaceToFree,
  182.                 IEmptyVolumeCacheCallBack *picb
  183.                 );
  184.                 
  185.     STDMETHODIMP    ShowProperties(
  186.                 HWND hwnd
  187.                 );
  188.                 
  189.     STDMETHODIMP    Deactivate(
  190.                 DWORD *pdwFlags
  191.                 );                                                                                                                                
  192.     STDMETHODIMP    InitializeEx(
  193.                 HKEY hRegKey,
  194.                 LPCWSTR pcwszVolume,
  195.                 LPCWSTR pcwszKeyName,
  196.                 LPWSTR *ppwszDisplayName,
  197.                 LPWSTR *ppwszDescription,
  198.                 LPWSTR *ppwszBtnText,
  199.                 DWORD *pdwFlags
  200.                 );
  201. };
  202. typedef CCompCleaner *LPCCOMPCLEANER;
  203. #endif // CCLEAN_H
  204. /*
  205. **------------------------------------------------------------------------------
  206. ** End of File
  207. **------------------------------------------------------------------------------
  208. */