appsize.cpp
Upload User: xhy777
Upload Date: 2007-02-14
Package Size: 24088k
Code Size: 2k
Category:

Windows Kernel

Development Platform:

Visual C++

  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.     CoInitialize(0);
  20. }
  21. CAppFolderSize::~CAppFolderSize()
  22. {
  23.     if (_pstw)
  24.         _pstw->Release();
  25.     CoUninitialize();
  26. }
  27. HRESULT CAppFolderSize::QueryInterface(REFIID riid, LPVOID * ppvOut)
  28.     static const QITAB qit[] = {
  29.         QITABENT(CAppFolderSize, IShellTreeWalkerCallBack),       // IID_IShellTreeWalkerCallBack
  30.         { 0 },
  31.     };
  32.     return QISearch(this, qit, riid, ppvOut);
  33. }
  34. ULONG CAppFolderSize::AddRef()
  35. {
  36.     _cRef++;
  37.     return _cRef;
  38. }
  39. ULONG CAppFolderSize::Release()
  40. {
  41.     _cRef--;
  42.     if (_cRef > 0)
  43.         return _cRef;
  44.     delete this;
  45.     return 0;
  46. }
  47. HRESULT CAppFolderSize::Initialize()
  48. {
  49.     return CoCreateInstance(CLSID_CShellTreeWalker, NULL, CLSCTX_INPROC_SERVER, IID_IShellTreeWalker, (LPVOID *)&_pstw);
  50. }   
  51. //
  52. // IShellTreeWalkerCallBack::FoundFile 
  53. //
  54. HRESULT CAppFolderSize::FoundFile(LPCWSTR pwszFolder, LPTREEWALKERSTATS ptws, WIN32_FIND_DATAW * pwfd)
  55. {
  56.     HRESULT hres = S_OK;
  57.     if (_puSize)
  58.         *_puSize = ptws->ulActualSize;
  59.     return hres;
  60. }
  61. HRESULT CAppFolderSize::EnterFolder(LPCWSTR pwszFolder, LPTREEWALKERSTATS ptws, WIN32_FIND_DATAW * pwfd)
  62. {
  63.     return E_NOTIMPL;
  64. }
  65. //
  66. // IShellTreeWalkerCallBack::LeaveFolder
  67. //
  68. HRESULT CAppFolderSize::LeaveFolder(LPCWSTR pwszFolder, LPTREEWALKERSTATS ptws)
  69. {
  70.     return E_NOTIMPL;
  71. }
  72. //
  73. // IShellTreeWalkerCallBack::HandleError 
  74. //
  75. HRESULT CAppFolderSize::HandleError(LPCWSTR pwszFolder, LPTREEWALKERSTATS ptws, HRESULT ErrorCode)
  76. {
  77.     return E_NOTIMPL;
  78. }
  79. #endif //DOWNLEVEL_PLATFORM