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

Windows Kernel

Development Platform:

Visual C++

  1. #include "priv.h"
  2. // Do not build this file if on Win9X or NT4
  3. #ifndef DOWNLEVEL_PLATFORM
  4. #include "darpub.h"
  5. #include "darenum.h"
  6. #include "sccls.h"
  7. #include "util.h"
  8. /////////////////////////////////////////////////////////////////////////////
  9. // CDarwinAppPublisher
  10. // Very thin layer around the darwin CoGet* API's
  11. // constructor
  12. CDarwinAppPublisher::CDarwinAppPublisher() : _cRef(1)
  13. {
  14.     DllAddRef();
  15.     TraceAddRef(CDarwinAppPub, _cRef);
  16. }
  17. // destructor
  18. CDarwinAppPublisher::~CDarwinAppPublisher()
  19. {
  20.     DllRelease();
  21. }
  22. // IAppPublisher::QueryInterface
  23. HRESULT CDarwinAppPublisher::QueryInterface(REFIID riid, LPVOID * ppvOut)
  24.      static const QITAB qit[] = {
  25.         QITABENT(CDarwinAppPublisher, IAppPublisher),                  // IID_IAppPublisher
  26.         { 0 },
  27.     };
  28.     return QISearch(this, qit, riid, ppvOut);
  29. }
  30. // IAppPublisher::AddRef
  31. ULONG CDarwinAppPublisher::AddRef()
  32. {
  33.     _cRef++;
  34.     TraceAddRef(CDarwinAppPub, _cRef);
  35.     return _cRef;
  36. }
  37. // IAppPublisher::Release
  38. ULONG CDarwinAppPublisher::Release()
  39. {
  40.     _cRef--;
  41.     TraceRelease(CDarwinAppPub, _cRef);
  42.     if (_cRef > 0)
  43.         return _cRef;
  44.     delete this;
  45.     return 0;
  46. }
  47. // IAppPublisher::GetNumberOfCategories
  48. STDMETHODIMP CDarwinAppPublisher::GetNumberOfCategories(DWORD * pdwCat)
  49. {
  50.     return E_NOTIMPL;
  51. }
  52. // IAppPublisher::GetCategories
  53. STDMETHODIMP CDarwinAppPublisher::GetCategories(APPCATEGORYINFOLIST * pAppCategoryList)
  54. {
  55.     HRESULT hres = E_FAIL;
  56.     RIP(pAppCategoryList);
  57.     ZeroMemory(pAppCategoryList, SIZEOF(APPCATEGORYINFOLIST));
  58.     APPCATEGORYINFOLIST acil = {0};
  59.     hres = CsGetAppCategories(&acil);
  60.     if (SUCCEEDED(hres) && (acil.cCategory > 0))
  61.     {
  62.         hres = _DuplicateCategoryList(&acil, pAppCategoryList);
  63.         ReleaseAppCategoryInfoList(&acil);
  64.     }
  65.     
  66.     return hres;
  67. }
  68. // IAppPublisher::GetNumberOfApps
  69. STDMETHODIMP CDarwinAppPublisher::GetNumberOfApps(DWORD * pdwApps)
  70. {
  71.     return E_NOTIMPL;
  72. }
  73. // IAppPublisher::EnumApps
  74. STDMETHODIMP CDarwinAppPublisher::EnumApps(GUID * pAppCategoryId, IEnumPublishedApps ** ppepa)
  75. {
  76.     HRESULT hres = E_FAIL;
  77.     CDarwinEnumPublishedApps * pdepa = new CDarwinEnumPublishedApps(pAppCategoryId);
  78.     if (pdepa)
  79.     {
  80.         *ppepa = SAFECAST(pdepa, IEnumPublishedApps *);
  81.         hres = S_OK;
  82.     }
  83.     else
  84.         hres = E_OUTOFMEMORY;
  85.     return hres;
  86.     
  87. }
  88. /*----------------------------------------------------------
  89. Purpose: Create-instance function for class factory
  90. */
  91. STDAPI CDarwinAppPublisher_CreateInstance(IUnknown* pUnkOuter, IUnknown** ppunk, LPCOBJECTINFO poi)
  92. {
  93.     // aggregation checking is handled in class factory
  94.     HRESULT hres = E_OUTOFMEMORY;
  95.     CDarwinAppPublisher* pObj = new CDarwinAppPublisher();
  96.     if (pObj)
  97.     {
  98.         *ppunk = SAFECAST(pObj, IAppPublisher *);
  99.         hres = S_OK;
  100.     }
  101.     return hres;
  102. }
  103. #endif //DOWNLEVEL_PLATFORM