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.

104 lines
1.8 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996 - 1999
  5. //
  6. // File: cienum.cpp
  7. //
  8. // Contents: Extension and Attribute enumerator
  9. //
  10. // History: 12-Mar-96 vich created
  11. //
  12. //---------------------------------------------------------------------------
  13. #include <pch.cpp>
  14. #pragma hdrstop
  15. #include "csprop.h"
  16. #include "csdisp.h"
  17. HRESULT
  18. CIENUM::EnumSetup(
  19. IN DWORD RequestId,
  20. IN LONG Context,
  21. IN DWORD Flags)
  22. {
  23. HRESULT hr;
  24. EnumClose();
  25. ICertDBRow *prow = NULL;
  26. hr = g_pCertDB->OpenRow(PROPOPEN_READONLY | PROPTABLE_REQCERT, RequestId, NULL, &prow);
  27. _JumpIfError(hr, error, "OpenRow");
  28. hr = prow->EnumCertDBName(~CIE_CALLER_MASK & Flags, &m_penum);
  29. _JumpIfError(hr, error, "EnumCertDBName");
  30. m_Context = Context;
  31. m_Flags = Flags;
  32. error:
  33. if (NULL != prow)
  34. {
  35. prow->Release();
  36. }
  37. return(hr);
  38. }
  39. HRESULT
  40. CIENUM::EnumNext(OUT BSTR *pstrPropertyName)
  41. {
  42. HRESULT hr = E_UNEXPECTED;
  43. CERTDBNAME cdbn;
  44. cdbn.pwszName = NULL;
  45. if (NULL == pstrPropertyName)
  46. {
  47. hr = E_POINTER;
  48. _JumpError(hr, error, "pstrPropertyName NULL");
  49. }
  50. if (NULL != *pstrPropertyName)
  51. {
  52. SysFreeString(*pstrPropertyName);
  53. *pstrPropertyName = NULL;
  54. }
  55. if (NULL != m_penum)
  56. {
  57. ULONG celtFetched;
  58. hr = m_penum->Next(1, &cdbn, &celtFetched);
  59. _JumpIfError2(hr, error, "Next", S_FALSE);
  60. CSASSERT(1 == celtFetched);
  61. CSASSERT(NULL != cdbn.pwszName);
  62. if (!ConvertWszToBstr(pstrPropertyName, cdbn.pwszName, -1))
  63. {
  64. hr = E_OUTOFMEMORY;
  65. goto error;
  66. }
  67. }
  68. error:
  69. if (NULL != cdbn.pwszName)
  70. {
  71. CoTaskMemFree(cdbn.pwszName);
  72. }
  73. return(hr);
  74. }
  75. HRESULT
  76. CIENUM::EnumClose()
  77. {
  78. if (NULL != m_penum)
  79. {
  80. m_penum->Release();
  81. m_penum = NULL;
  82. }
  83. return(S_OK);
  84. }