Source code of Windows XP (NT5)
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.

106 lines
2.2 KiB

  1. //---------------------------------------------------------------------------
  2. //
  3. // Copyright (c) Microsoft Corporation
  4. //
  5. // File: appsize.cpp
  6. //
  7. // Compute the size of an application
  8. //
  9. // History:
  10. // 2-17-98 by dli implemented CAppFolderSize
  11. //------------------------------------------------------------------------
  12. #include "priv.h"
  13. // Do not build this file if on Win9X or NT4
  14. #ifndef DOWNLEVEL_PLATFORM
  15. #include "appsize.h"
  16. // NOTE: CAppFolderSize and CAppFolderFinder are very similar to C*TreeWalkCB in Shell32.
  17. CAppFolderSize::CAppFolderSize(ULONGLONG * puSize): _cRef(1), _puSize(puSize)
  18. {
  19. _hrCoInit = CoInitialize(NULL);
  20. }
  21. CAppFolderSize::~CAppFolderSize()
  22. {
  23. if (_pstw)
  24. _pstw->Release();
  25. if (SUCCEEDED(_hrCoInit))
  26. {
  27. CoUninitialize();
  28. }
  29. }
  30. HRESULT CAppFolderSize::QueryInterface(REFIID riid, LPVOID * ppvOut)
  31. {
  32. static const QITAB qit[] = {
  33. QITABENT(CAppFolderSize, IShellTreeWalkerCallBack), // IID_IShellTreeWalkerCallBack
  34. { 0 },
  35. };
  36. return QISearch(this, qit, riid, ppvOut);
  37. }
  38. ULONG CAppFolderSize::AddRef()
  39. {
  40. _cRef++;
  41. return _cRef;
  42. }
  43. ULONG CAppFolderSize::Release()
  44. {
  45. _cRef--;
  46. if (_cRef > 0)
  47. return _cRef;
  48. delete this;
  49. return 0;
  50. }
  51. HRESULT CAppFolderSize::Initialize()
  52. {
  53. HRESULT hr = _hrCoInit;
  54. if (SUCCEEDED(hr))
  55. {
  56. hr = CoCreateInstance(CLSID_CShellTreeWalker, NULL, CLSCTX_INPROC_SERVER, IID_IShellTreeWalker, (LPVOID *)&_pstw);
  57. }
  58. return hr;
  59. }
  60. //
  61. // IShellTreeWalkerCallBack::FoundFile
  62. //
  63. HRESULT CAppFolderSize::FoundFile(LPCWSTR pwszFolder, TREEWALKERSTATS *ptws, WIN32_FIND_DATAW * pwfd)
  64. {
  65. HRESULT hres = S_OK;
  66. if (_puSize)
  67. *_puSize = ptws->ulActualSize;
  68. return hres;
  69. }
  70. HRESULT CAppFolderSize::EnterFolder(LPCWSTR pwszFolder, TREEWALKERSTATS *ptws, WIN32_FIND_DATAW * pwfd)
  71. {
  72. return E_NOTIMPL;
  73. }
  74. //
  75. // IShellTreeWalkerCallBack::LeaveFolder
  76. //
  77. HRESULT CAppFolderSize::LeaveFolder(LPCWSTR pwszFolder, TREEWALKERSTATS *ptws)
  78. {
  79. return E_NOTIMPL;
  80. }
  81. //
  82. // IShellTreeWalkerCallBack::HandleError
  83. //
  84. HRESULT CAppFolderSize::HandleError(LPCWSTR pwszFolder, TREEWALKERSTATS *ptws, HRESULT ErrorCode)
  85. {
  86. return E_NOTIMPL;
  87. }
  88. #endif //DOWNLEVEL_PLATFORM