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.

173 lines
4.1 KiB

  1. #ifndef HSI
  2. #define HSI
  3. #include <stdlib.h>
  4. //
  5. // From HelpServiceTypeLib.idl
  6. //
  7. #include <HelpServiceTypeLib.h>
  8. //
  9. // From HelpCenterTypeLib.idl
  10. //
  11. #include <HelpCenterTypeLib.h>
  12. class ATL_NO_VTABLE CHSItem :
  13. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  14. public IDispatchImpl<IPCHHelpSessionItem, &IID_IPCHHelpSessionItem, &LIBID_HelpServiceTypeLib>
  15. {
  16. public:
  17. BEGIN_COM_MAP(CHSItem)
  18. COM_INTERFACE_ENTRY(IDispatch)
  19. COM_INTERFACE_ENTRY(IPCHHelpSessionItem)
  20. END_COM_MAP()
  21. CComBSTR m_bstrURL;
  22. CComBSTR m_bstrTitle;
  23. DATE m_dtLV;
  24. DATE m_dtDur;
  25. long m_cHits;
  26. HRESULT Init(BSTR bstrURL, BSTR bstrTitle, DATE dtLV, DATE dtDur, long cHits)
  27. {
  28. m_bstrURL = bstrURL;
  29. m_bstrTitle = bstrTitle;
  30. m_dtLV = dtLV;
  31. m_dtDur = dtDur;
  32. m_cHits = cHits;
  33. return NOERROR;
  34. }
  35. // IPCHHelpSessionItem
  36. STDMETHOD(get_SKU )( /*[out, retval]*/ BSTR *pVal )
  37. {
  38. return E_NOTIMPL;
  39. }
  40. STDMETHOD(get_Language )( /*[out, retval]*/ long *pVal )
  41. {
  42. return E_NOTIMPL;
  43. }
  44. STDMETHOD(get_URL )( /*[out, retval]*/ BSTR *pVal )
  45. {
  46. if ((*pVal = SysAllocString(m_bstrURL.m_str)) == NULL)
  47. return E_OUTOFMEMORY;
  48. return NOERROR;
  49. }
  50. STDMETHOD(get_Title )( /*[out, retval]*/ BSTR *pVal )
  51. {
  52. if ((*pVal = SysAllocString(m_bstrTitle.m_str)) == NULL)
  53. return E_OUTOFMEMORY;
  54. return NOERROR;
  55. }
  56. STDMETHOD(get_LastVisited)( /*[out, retval]*/ DATE *pVal )
  57. {
  58. *pVal = m_dtLV;
  59. return NOERROR;
  60. }
  61. STDMETHOD(get_Duration )( /*[out, retval]*/ DATE *pVal )
  62. {
  63. *pVal = m_dtDur;
  64. return NOERROR;
  65. }
  66. STDMETHOD(get_NumOfHits )( /*[out, retval]*/ long *pVal )
  67. {
  68. *pVal = m_cHits;
  69. return NOERROR;
  70. }
  71. STDMETHOD(get_Property)( /*[in]*/ BSTR bstrName, /*[out, retval]*/ VARIANT * pVal )
  72. {
  73. return E_NOTIMPL;
  74. }
  75. STDMETHOD(put_Property)( /*[in]*/ BSTR bstrName, /*[in]*/ VARIANT newVal )
  76. {
  77. return E_NOTIMPL;
  78. }
  79. STDMETHOD(get_ContextName)( /*[out, retval]*/ BSTR *pVal )
  80. {
  81. return E_NOTIMPL;
  82. }
  83. STDMETHOD(get_ContextInfo)( /*[out, retval]*/ BSTR *pVal )
  84. {
  85. return E_NOTIMPL;
  86. }
  87. STDMETHOD(get_ContextURL)( /*[out, retval]*/ BSTR *pVal )
  88. {
  89. return E_NOTIMPL;
  90. }
  91. STDMETHOD(CheckProperty)( /*[in]*/ BSTR bstrName, /*[out, retval]*/ VARIANT_BOOL *pVal )
  92. {
  93. return E_NOTIMPL;
  94. }
  95. };
  96. class ATL_NO_VTABLE CHSC :
  97. public CComObjectRootEx<MPC::CComSafeMultiThreadModel>,
  98. public IDispatchImpl<IPCHCollection, &IID_IPCHCollection, &LIBID_HelpServiceTypeLib>
  99. {
  100. public:
  101. BEGIN_COM_MAP(CHSC)
  102. COM_INTERFACE_ENTRY(IDispatch)
  103. COM_INTERFACE_ENTRY(IPCHCollection)
  104. END_COM_MAP()
  105. STDMETHOD(get__NewEnum)(IUnknown **pVal) { return E_NOTIMPL; }
  106. STDMETHOD(get_Item )(long vIndex, VARIANT *pEntry)
  107. {
  108. CComObject<CHSItem> *phsi = NULL;
  109. SYSTEMTIME st;
  110. CComBSTR bstrURL, bstrTitle;
  111. HRESULT hr = NOERROR;
  112. WCHAR wsz[14];
  113. DATE dtLast, dtDur;
  114. _itow(vIndex, wsz, 10);
  115. bstrURL = L"URL";
  116. bstrURL.Append(wsz);
  117. bstrTitle = L"Title";
  118. bstrTitle.Append(wsz);
  119. GetSystemTime(&st);
  120. SystemTimeToVariantTime(&st, &dtLast);
  121. Sleep(516);
  122. GetSystemTime(&st);
  123. SystemTimeToVariantTime(&st, &dtDur);
  124. dtDur = dtDur - dtLast;
  125. hr = CComObject<CHSItem>::CreateInstance(&phsi);
  126. if (FAILED(hr))
  127. goto done;
  128. hr = phsi->Init(bstrURL, bstrTitle, dtLast, dtDur, vIndex);
  129. if (FAILED(hr))
  130. goto done;
  131. V_VT(pEntry) = VT_DISPATCH;
  132. V_DISPATCH(pEntry) = phsi;
  133. phsi = NULL;
  134. done:
  135. if (phsi != NULL)
  136. phsi->Release();
  137. return hr;
  138. }
  139. STDMETHOD(get_Count)(long *pVal) { *pVal = 3; return NOERROR; }
  140. };
  141. #endif