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.

142 lines
3.7 KiB

  1. // DateTime.h : Declaration of the CDateTime
  2. #ifndef __DATETIME_H_
  3. #define __DATETIME_H_
  4. #include "resource.h" // main symbols
  5. //
  6. // Tasks that are supports by this COM Server
  7. //
  8. typedef enum
  9. {
  10. NONE_FOUND,
  11. SET_DATE_TIME,
  12. SET_TIME_ZONE,
  13. RAISE_SETDATETIME_ALERT
  14. } SET_DATE_TIME_TASK_TYPE;
  15. #define TZNAME_SIZE 128
  16. #define TZDISPLAYZ 128
  17. //
  18. // Registry info goes in this structure.
  19. //
  20. typedef struct tagTZINFO
  21. {
  22. struct tagTZINFO *next;
  23. TCHAR szDisplayName[TZDISPLAYZ];
  24. TCHAR szStandardName[TZNAME_SIZE];
  25. TCHAR szDaylightName[TZNAME_SIZE];
  26. LONG Bias;
  27. LONG StandardBias;
  28. LONG DaylightBias;
  29. SYSTEMTIME StandardDate;
  30. SYSTEMTIME DaylightDate;
  31. } TZINFO, *PTZINFO;
  32. /////////////////////////////////////////////////////////////////////////////
  33. // CDateTime
  34. class ATL_NO_VTABLE CDateTime :
  35. public CComObjectRootEx<CComSingleThreadModel>,
  36. public CComCoClass<CDateTime, &CLSID_DateTime>,
  37. public IDispatchImpl<IApplianceTask, &IID_IApplianceTask, &LIBID_SETDATETIMELib>
  38. {
  39. public:
  40. CDateTime()
  41. {
  42. ZeroMemory(&m_OldDateTime, sizeof(SYSTEMTIME));
  43. ZeroMemory(&m_OldTimeZoneInformation, sizeof(TIME_ZONE_INFORMATION));
  44. }
  45. DECLARE_REGISTRY_RESOURCEID(IDR_DATETIME)
  46. DECLARE_PROTECT_FINAL_CONSTRUCT()
  47. BEGIN_COM_MAP(CDateTime)
  48. COM_INTERFACE_ENTRY(IApplianceTask)
  49. COM_INTERFACE_ENTRY(IDispatch)
  50. END_COM_MAP()
  51. //
  52. // IApplianceTask
  53. //
  54. STDMETHOD(OnTaskExecute)(
  55. /*[in]*/ IUnknown* pTaskContext
  56. );
  57. STDMETHOD(OnTaskComplete)(
  58. /*[in]*/ IUnknown* pTaskContext,
  59. /*[in]*/ LONG lTaskResult
  60. );
  61. private:
  62. SYSTEMTIME m_OldDateTime;
  63. TIME_ZONE_INFORMATION m_OldTimeZoneInformation;
  64. BOOL m_OldEnableDayLightSaving;
  65. SET_DATE_TIME_TASK_TYPE GetMethodName(IN ITaskContext *pTaskParameter);
  66. //
  67. // Functions to raise the Set Date/Time alert
  68. //
  69. STDMETHODIMP RaiseSetDateTimeAlert(void);
  70. BOOL ShouldRaiseDateTimeAlert(void);
  71. BOOL DoNotRaiseDateTimeAlert(void);
  72. BOOL ClearDateTimeAlert(void);
  73. //
  74. // Functions for Setting Date/Time
  75. //
  76. STDMETHODIMP GetSetDateTimeParameters(IN ITaskContext *pTaskContext,
  77. OUT SYSTEMTIME *pLocalTime);
  78. STDMETHODIMP SetDateTime(IN ITaskContext *pTaskContext);
  79. STDMETHODIMP RollbackSetDateTime(IN ITaskContext *pTaskContext);
  80. //
  81. // Functions for Setting Time Zone information
  82. //
  83. STDMETHODIMP GetSetTimeZoneParameters(IN ITaskContext *pTaskContext,
  84. OUT LPTSTR *lpStandardTimeZoneName,
  85. OUT BOOL *pbEnableDayLightSavings);
  86. STDMETHODIMP SetTimeZone(IN ITaskContext *pTaskContext);
  87. STDMETHODIMP RollbackSetTimeZone(IN ITaskContext *pTaskContext);
  88. //
  89. // Helper function for get/set Time Zone information
  90. //
  91. BOOL ReadZoneData(PTZINFO zone, HKEY key, LPCTSTR keyname);
  92. int ReadTimezones(PTZINFO *list);
  93. void AddZoneToList(PTZINFO *list, PTZINFO zone);
  94. void FreeTimezoneList(PTZINFO *list);
  95. void SetTheTimezone(BOOL bAutoMagicTimeChange, PTZINFO ptzi);
  96. void SetAllowLocalTimeChange(BOOL fAllow);
  97. BOOL GetAllowLocalTimeChange(void);
  98. };
  99. #endif //__DATETIME_H_