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.

110 lines
3.6 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 2000.
  5. //
  6. // File: N C S Y S P R P . H
  7. //
  8. // Contents: INetCfgSysPrep interface declaration
  9. //
  10. // Notes:
  11. //
  12. // Author: FrankLi 22-April-2000
  13. //
  14. //----------------------------------------------------------------------------
  15. #pragma once
  16. #include <objbase.h>
  17. #include <atlbase.h>
  18. extern CComModule _Module;
  19. #include <atlcom.h>
  20. #include "netcfgx.h"
  21. #include "netcfgn.h"
  22. // helpers used by implementation of INetCfgSysPrep to save notify object's
  23. // registry settings into CWInfFile object
  24. // note: these functions are not thread safe.
  25. typedef LPVOID HWIF; // an opaque type for out internal HrSetupSetXxx APIs
  26. HRESULT
  27. HrSetupSetFirstDword (IN HWIF hwif,
  28. IN PCWSTR pwszSection, // section
  29. IN PCWSTR pwszKey, // Answer-File key
  30. IN DWORD dwValue); // Answer-File value
  31. HRESULT
  32. HrSetupSetFirstString (IN HWIF hwif,
  33. IN PCWSTR pwszSection,
  34. IN PCWSTR pwszKey,
  35. IN PCWSTR pwszValue);
  36. HRESULT
  37. HrSetupSetFirstStringAsBool (IN HWIF hwif,
  38. IN PCWSTR pwszSection,
  39. IN PCWSTR pwszKey,
  40. IN BOOL fValue);
  41. HRESULT
  42. HrSetupSetFirstMultiSzField (IN HWIF hwif,
  43. IN PCWSTR pwszSection,
  44. IN PCWSTR pwszKey,
  45. IN PCWSTR pmszValue);
  46. // Implementation of INetCfgSysPrep interface.
  47. // We don't need a class factory, we just need the IUnknown
  48. // implementation from ATL
  49. class ATL_NO_VTABLE CNetCfgSysPrep :
  50. public CComObjectRoot,
  51. public INetCfgSysPrep
  52. {
  53. public:
  54. CNetCfgSysPrep() : m_hwif(NULL) {};
  55. ~CNetCfgSysPrep() {DeleteCriticalSection(&m_csWrite);};
  56. BEGIN_COM_MAP(CNetCfgSysPrep)
  57. COM_INTERFACE_ENTRY(INetCfgSysPrep)
  58. END_COM_MAP()
  59. // INetCfgSysPrep methods
  60. STDMETHOD (HrSetupSetFirstDword) (
  61. /* [in] */ PCWSTR pwszSection,
  62. /* [in] */ PCWSTR pwszKey,
  63. /* [in] */ DWORD dwValue
  64. );
  65. STDMETHOD (HrSetupSetFirstString) (
  66. /* [in] */ PCWSTR pwszSection,
  67. /* [in] */ PCWSTR pwszKey,
  68. /* [in] */ PCWSTR pwszValue
  69. );
  70. STDMETHOD (HrSetupSetFirstStringAsBool) (
  71. /* [in] */ PCWSTR pwszSection,
  72. /* [in] */ PCWSTR pwszKey,
  73. /* [in] */ BOOL fValue
  74. );
  75. STDMETHOD (HrSetupSetFirstMultiSzField) (
  76. /* [in] */ PCWSTR pwszSection,
  77. /* [in] */ PCWSTR pwszKey,
  78. /* [in] */ PCWSTR pmszValue
  79. );
  80. HRESULT HrInit(HWIF hwif)
  81. {
  82. m_hwif = hwif;
  83. __try
  84. {
  85. InitializeCriticalSection(&m_csWrite);
  86. return S_OK;
  87. }
  88. __except(GetExceptionCode() == STATUS_NO_MEMORY )
  89. {
  90. return (E_OUTOFMEMORY);
  91. }
  92. // return E_FAIL for any other exception codes
  93. return E_FAIL;
  94. };
  95. void SetHWif(HWIF hwif) {EnterCriticalSection(&m_csWrite);m_hwif = hwif;LeaveCriticalSection(&m_csWrite);};
  96. protected:
  97. HWIF m_hwif; // handle that will pass to ::HrSetupSetXxx internal APIs
  98. CRITICAL_SECTION m_csWrite; // crtical section to protect non-atomic writes
  99. };