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.

113 lines
3.4 KiB

  1. // NTFS Compression Disk Cleanup cleaner
  2. #ifndef COMPCLEN_H
  3. #define COMPCLEN_H
  4. #include "common.h"
  5. #define COMPCLN_REGPATH TEXT("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\VolumeCaches\\Compress old files")
  6. #define MAX_DAYS 500 // Settings dialog spin control max
  7. #define MIN_DAYS 1 // Settings dialog spin control min
  8. #define DEFAULT_DAYS 50 // Default #days if no setting in registry
  9. // Manufactures instances of our CCompCleaner object
  10. class CCompCleanerClassFactory : public IClassFactory
  11. {
  12. private:
  13. ULONG m_cRef; // Reference count
  14. ~CCompCleanerClassFactory();
  15. public:
  16. CCompCleanerClassFactory();
  17. // IUnknown
  18. STDMETHODIMP QueryInterface(REFIID, void **);
  19. STDMETHODIMP_(ULONG) AddRef(void);
  20. STDMETHODIMP_(ULONG) Release(void);
  21. // IClassFactory
  22. STDMETHODIMP CreateInstance(IUnknown *, REFIID, void **);
  23. STDMETHODIMP LockServer(BOOL);
  24. };
  25. // the Compression Cleaner Class
  26. class CCompCleaner : public IEmptyVolumeCache2
  27. {
  28. private:
  29. ULONG m_cRef; // reference count
  30. ULARGE_INTEGER cbSpaceUsed;
  31. ULARGE_INTEGER cbSpaceFreed;
  32. FILETIME ftMinLastAccessTime;
  33. TCHAR szVolume[MAX_PATH];
  34. TCHAR szFolder[MAX_PATH];
  35. BOOL bPurged; // TRUE if Purge() method was run
  36. BOOL bSettingsMode; // TRUE if currently in settings mode
  37. CLEANFILESTRUCT *head;
  38. BOOL AddDirToList(LPCTSTR lpPath);
  39. void FreeList(CLEANFILESTRUCT *pCleanFile);
  40. BOOL WalkForUsedSpace(LPCTSTR lpPath, IEmptyVolumeCacheCallBack *picb, BOOL bCompress, int depth);
  41. BOOL CompressFile(IEmptyVolumeCacheCallBack *picb, LPCTSTR lpFile, ULARGE_INTEGER filesize);
  42. void WalkFileSystem(IEmptyVolumeCacheCallBack *picb, BOOL bCompress);
  43. void CalcLADFileTime();
  44. BOOL LastAccessisOK(FILETIME ftFileLastAccess);
  45. ~CCompCleaner(void);
  46. public:
  47. CCompCleaner(void);
  48. // IUnknown
  49. STDMETHODIMP QueryInterface(REFIID, void **);
  50. STDMETHODIMP_(ULONG) AddRef(void);
  51. STDMETHODIMP_(ULONG) Release(void);
  52. //
  53. // IEmptyVolumeCache2 interface members
  54. //
  55. STDMETHODIMP Initialize(
  56. HKEY hRegKey,
  57. LPCWSTR pszVolume,
  58. LPWSTR *ppszDisplayName,
  59. LPWSTR *ppszDescription,
  60. DWORD *pdwFlags
  61. );
  62. STDMETHODIMP GetSpaceUsed(
  63. DWORDLONG *pdwSpaceUsed,
  64. IEmptyVolumeCacheCallBack *picb
  65. );
  66. STDMETHODIMP Purge(
  67. DWORDLONG dwSpaceToFree,
  68. IEmptyVolumeCacheCallBack *picb
  69. );
  70. STDMETHODIMP ShowProperties(
  71. HWND hwnd
  72. );
  73. STDMETHODIMP Deactivate(
  74. DWORD *pdwFlags
  75. );
  76. STDMETHODIMP InitializeEx(
  77. HKEY hRegKey,
  78. LPCWSTR pcwszVolume,
  79. LPCWSTR pcwszKeyName,
  80. LPWSTR *ppwszDisplayName,
  81. LPWSTR *ppwszDescription,
  82. LPWSTR *ppwszBtnText,
  83. DWORD *pdwFlags
  84. );
  85. };
  86. #endif // CCLEAN_H