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.

349 lines
6.6 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1995 - 1999
  6. //
  7. // File: viewattr.cpp
  8. //
  9. // Contents: IEnumCERTVIEWATTRIBUTE IDispatch helper functions
  10. //
  11. //--------------------------------------------------------------------------
  12. #include <pch.cpp>
  13. #pragma hdrstop
  14. #include <stdlib.h>
  15. #include "csdisp.h"
  16. #include "csprop.h"
  17. //+------------------------------------------------------------------------
  18. // IEnumCERTVIEWATTRIBUTE dispatch support
  19. //+------------------------------------
  20. // OpenConnection method:
  21. static OLECHAR *_apszNext[] = {
  22. TEXT("Next"),
  23. };
  24. //+------------------------------------
  25. // GetName method:
  26. static OLECHAR *_apszGetName[] = {
  27. TEXT("GetName"),
  28. };
  29. //+------------------------------------
  30. // GetValue method:
  31. static OLECHAR *_apszGetValue[] = {
  32. TEXT("GetValue"),
  33. };
  34. //+------------------------------------
  35. // Skip method:
  36. static OLECHAR *_apszSkip[] = {
  37. TEXT("Skip"),
  38. TEXT("celt"),
  39. };
  40. //+------------------------------------
  41. // Reset method:
  42. static OLECHAR *_apszReset[] = {
  43. TEXT("Reset"),
  44. };
  45. //+------------------------------------
  46. // Clone method:
  47. static OLECHAR *_apszClone[] = {
  48. TEXT("Clone"),
  49. };
  50. //+------------------------------------
  51. // Dispatch Table:
  52. DISPATCHTABLE g_adtViewAttribute[] =
  53. {
  54. #define VIEWATTR_NEXT 0
  55. DECLARE_DISPATCH_ENTRY(_apszNext)
  56. #define VIEWATTR_GETNAME 1
  57. DECLARE_DISPATCH_ENTRY(_apszGetName)
  58. #define VIEWATTR_GETVALUE 2
  59. DECLARE_DISPATCH_ENTRY(_apszGetValue)
  60. #define VIEWATTR_SKIP 3
  61. DECLARE_DISPATCH_ENTRY(_apszSkip)
  62. #define VIEWATTR_RESET 4
  63. DECLARE_DISPATCH_ENTRY(_apszReset)
  64. #define VIEWATTR_CLONE 5
  65. DECLARE_DISPATCH_ENTRY(_apszClone)
  66. };
  67. #define CVIEWATTRDISPATCH (ARRAYSIZE(g_adtViewAttribute))
  68. HRESULT
  69. ViewAttribute_Init2(
  70. IN BOOL fIDispatch,
  71. IN IEnumCERTVIEWATTRIBUTE *pEnumAttribute,
  72. OUT DISPATCHINTERFACE *pdiViewAttribute)
  73. {
  74. HRESULT hr;
  75. IDispatch *pDispatch = NULL;
  76. static BOOL s_fInitialized = FALSE;
  77. pdiViewAttribute->pDispatchTable = NULL;
  78. pdiViewAttribute->pDispatch = NULL;
  79. pdiViewAttribute->pUnknown = NULL;
  80. if (fIDispatch)
  81. {
  82. hr = pEnumAttribute->QueryInterface(
  83. IID_IDispatch,
  84. (VOID **) &pDispatch);
  85. _JumpIfError(hr, error, "QueryInterface");
  86. hr = DispatchGetIds(
  87. pDispatch,
  88. CVIEWATTRDISPATCH,
  89. g_adtViewAttribute,
  90. pdiViewAttribute);
  91. _JumpIfError(hr, error, "DispatchGetIds");
  92. pdiViewAttribute->pDispatch = pDispatch;
  93. pDispatch = NULL;
  94. }
  95. else
  96. {
  97. pEnumAttribute->AddRef();
  98. pdiViewAttribute->pUnknown = (IUnknown *) pEnumAttribute;
  99. hr = S_OK;
  100. }
  101. pdiViewAttribute->pDispatchTable = g_adtViewAttribute;
  102. error:
  103. if (NULL != pDispatch)
  104. {
  105. pDispatch->Release();
  106. }
  107. return(hr);
  108. }
  109. VOID
  110. ViewAttribute_Release(
  111. IN OUT DISPATCHINTERFACE *pdiViewAttribute)
  112. {
  113. DispatchRelease(pdiViewAttribute);
  114. }
  115. HRESULT
  116. ViewAttribute_Next(
  117. IN DISPATCHINTERFACE *pdiViewAttribute,
  118. OUT LONG *pIndex)
  119. {
  120. HRESULT hr;
  121. CSASSERT(NULL != pdiViewAttribute && NULL != pdiViewAttribute->pDispatchTable);
  122. if (NULL != pdiViewAttribute->pDispatch)
  123. {
  124. hr = DispatchInvoke(
  125. pdiViewAttribute,
  126. VIEWATTR_NEXT,
  127. 0,
  128. NULL,
  129. VT_I4,
  130. pIndex);
  131. _JumpIfError2(hr, error, "Invoke(Next)", S_FALSE);
  132. }
  133. else
  134. {
  135. hr = ((IEnumCERTVIEWATTRIBUTE *) pdiViewAttribute->pUnknown)->Next(pIndex);
  136. _JumpIfError2(hr, error, "Next", S_FALSE);
  137. }
  138. error:
  139. return(hr);
  140. }
  141. HRESULT
  142. ViewAttribute_GetName(
  143. IN DISPATCHINTERFACE *pdiViewAttribute,
  144. OUT BSTR *pstrOut)
  145. {
  146. HRESULT hr;
  147. CSASSERT(NULL != pdiViewAttribute && NULL != pdiViewAttribute->pDispatchTable);
  148. if (NULL != pdiViewAttribute->pDispatch)
  149. {
  150. hr = DispatchInvoke(
  151. pdiViewAttribute,
  152. VIEWATTR_GETNAME,
  153. 0,
  154. NULL,
  155. VT_BSTR,
  156. pstrOut);
  157. _JumpIfError(hr, error, "Invoke(GetName)");
  158. }
  159. else
  160. {
  161. hr = ((IEnumCERTVIEWATTRIBUTE *) pdiViewAttribute->pUnknown)->GetName(pstrOut);
  162. _JumpIfError(hr, error, "GetName");
  163. }
  164. error:
  165. return(hr);
  166. }
  167. HRESULT
  168. ViewAttribute_GetValue(
  169. IN DISPATCHINTERFACE *pdiViewAttribute,
  170. OUT BSTR *pstrOut)
  171. {
  172. HRESULT hr;
  173. CSASSERT(NULL != pdiViewAttribute && NULL != pdiViewAttribute->pDispatchTable);
  174. if (NULL != pdiViewAttribute->pDispatch)
  175. {
  176. hr = DispatchInvoke(
  177. pdiViewAttribute,
  178. VIEWATTR_GETVALUE,
  179. 0,
  180. NULL,
  181. VT_BSTR,
  182. pstrOut);
  183. _JumpIfError(hr, error, "Invoke(GetValue)");
  184. }
  185. else
  186. {
  187. hr = ((IEnumCERTVIEWATTRIBUTE *) pdiViewAttribute->pUnknown)->GetValue(
  188. pstrOut);
  189. _JumpIfError(hr, error, "GetValue");
  190. }
  191. error:
  192. return(hr);
  193. }
  194. HRESULT
  195. ViewAttribute_Skip(
  196. IN DISPATCHINTERFACE *pdiViewAttribute,
  197. IN LONG celt)
  198. {
  199. HRESULT hr;
  200. CSASSERT(NULL != pdiViewAttribute && NULL != pdiViewAttribute->pDispatchTable);
  201. if (NULL != pdiViewAttribute->pDispatch)
  202. {
  203. VARIANT avar[1];
  204. avar[0].vt = VT_I4;
  205. avar[0].lVal = celt;
  206. hr = DispatchInvoke(
  207. pdiViewAttribute,
  208. VIEWATTR_SKIP,
  209. ARRAYSIZE(avar),
  210. avar,
  211. 0,
  212. NULL);
  213. _JumpIfError(hr, error, "Invoke(Skip)");
  214. }
  215. else
  216. {
  217. hr = ((IEnumCERTVIEWATTRIBUTE *) pdiViewAttribute->pUnknown)->Skip(celt);
  218. _JumpIfError(hr, error, "Skip");
  219. }
  220. error:
  221. return(hr);
  222. }
  223. HRESULT
  224. ViewAttribute_Reset(
  225. IN DISPATCHINTERFACE *pdiViewAttribute)
  226. {
  227. HRESULT hr;
  228. CSASSERT(NULL != pdiViewAttribute && NULL != pdiViewAttribute->pDispatchTable);
  229. if (NULL != pdiViewAttribute->pDispatch)
  230. {
  231. hr = DispatchInvoke(
  232. pdiViewAttribute,
  233. VIEWATTR_RESET,
  234. 0,
  235. NULL,
  236. 0,
  237. NULL);
  238. _JumpIfError(hr, error, "Invoke(Reset)");
  239. }
  240. else
  241. {
  242. hr = ((IEnumCERTVIEWATTRIBUTE *) pdiViewAttribute->pUnknown)->Reset();
  243. _JumpIfError(hr, error, "Reset");
  244. }
  245. error:
  246. return(hr);
  247. }
  248. HRESULT
  249. ViewAttribute_Clone(
  250. IN DISPATCHINTERFACE *pdiViewAttribute,
  251. OUT DISPATCHINTERFACE *pdiViewAttributeClone)
  252. {
  253. HRESULT hr;
  254. IEnumCERTVIEWATTRIBUTE *pEnumAttribute = NULL;
  255. CSASSERT(NULL != pdiViewAttribute && NULL != pdiViewAttribute->pDispatchTable);
  256. if (NULL != pdiViewAttribute->pDispatch)
  257. {
  258. hr = DispatchInvoke(
  259. pdiViewAttribute,
  260. VIEWATTR_CLONE,
  261. 0,
  262. NULL,
  263. VT_DISPATCH,
  264. &pEnumAttribute);
  265. _JumpIfError(hr, error, "Invoke(Clone)");
  266. }
  267. else
  268. {
  269. hr = ((IEnumCERTVIEWATTRIBUTE *) pdiViewAttribute->pUnknown)->Clone(
  270. &pEnumAttribute);
  271. _JumpIfError(hr, error, "Clone");
  272. }
  273. hr = ViewAttribute_Init2(
  274. NULL != pdiViewAttribute->pDispatch,
  275. pEnumAttribute,
  276. pdiViewAttributeClone);
  277. _JumpIfError(hr, error, "ViewAttribute_Init2");
  278. error:
  279. if (NULL != pEnumAttribute)
  280. {
  281. pEnumAttribute->Release();
  282. }
  283. return(hr);
  284. }