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.

101 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. #include "appsize.h"
  14. // NOTE: CAppFolderSize and CAppFolderFinder are very similar to C*TreeWalkCB in Shell32.
  15. CAppFolderSize::CAppFolderSize(ULONGLONG * puSize): _cRef(1), _puSize(puSize)
  16. {
  17. _hrCoInit = CoInitialize(NULL);
  18. }
  19. CAppFolderSize::~CAppFolderSize()
  20. {
  21. if (_pstw)
  22. _pstw->Release();
  23. if (SUCCEEDED(_hrCoInit))
  24. {
  25. CoUninitialize();
  26. }
  27. }
  28. HRESULT CAppFolderSize::QueryInterface(REFIID riid, LPVOID * ppvOut)
  29. {
  30. static const QITAB qit[] = {
  31. QITABENT(CAppFolderSize, IShellTreeWalkerCallBack), // IID_IShellTreeWalkerCallBack
  32. { 0 },
  33. };
  34. return QISearch(this, qit, riid, ppvOut);
  35. }
  36. ULONG CAppFolderSize::AddRef()
  37. {
  38. _cRef++;
  39. return _cRef;
  40. }
  41. ULONG CAppFolderSize::Release()
  42. {
  43. _cRef--;
  44. if (_cRef > 0)
  45. return _cRef;
  46. delete this;
  47. return 0;
  48. }
  49. HRESULT CAppFolderSize::Initialize()
  50. {
  51. HRESULT hr = _hrCoInit;
  52. if (SUCCEEDED(hr))
  53. {
  54. hr = CoCreateInstance(CLSID_CShellTreeWalker, NULL, CLSCTX_INPROC_SERVER, IID_IShellTreeWalker, (LPVOID *)&_pstw);
  55. }
  56. return hr;
  57. }
  58. //
  59. // IShellTreeWalkerCallBack::FoundFile
  60. //
  61. HRESULT CAppFolderSize::FoundFile(LPCWSTR pwszFolder, TREEWALKERSTATS *ptws, WIN32_FIND_DATAW * pwfd)
  62. {
  63. HRESULT hres = S_OK;
  64. if (_puSize)
  65. *_puSize = ptws->ulActualSize;
  66. return hres;
  67. }
  68. HRESULT CAppFolderSize::EnterFolder(LPCWSTR pwszFolder, TREEWALKERSTATS *ptws, WIN32_FIND_DATAW * pwfd)
  69. {
  70. return E_NOTIMPL;
  71. }
  72. //
  73. // IShellTreeWalkerCallBack::LeaveFolder
  74. //
  75. HRESULT CAppFolderSize::LeaveFolder(LPCWSTR pwszFolder, TREEWALKERSTATS *ptws)
  76. {
  77. return E_NOTIMPL;
  78. }
  79. //
  80. // IShellTreeWalkerCallBack::HandleError
  81. //
  82. HRESULT CAppFolderSize::HandleError(LPCWSTR pwszFolder, TREEWALKERSTATS *ptws, HRESULT ErrorCode)
  83. {
  84. return E_NOTIMPL;
  85. }