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.

106 lines
3.3 KiB

  1. //*********************************************************************
  2. //* Microsoft Windows **
  3. //* Copyright(c) Microsoft Corp., 1999 **
  4. //*********************************************************************
  5. //
  6. // SYSCLOCK.H - Header for the implementation of CSystemClock
  7. //
  8. // HISTORY:
  9. //
  10. // 1/27/99 a-jaswed Created.
  11. //
  12. #ifndef _SYSCLOCK_H_
  13. #define _SYSCLOCK_H_
  14. #include <windows.h>
  15. #include <assert.h>
  16. #include <oleauto.h>
  17. #include <regstr.h>
  18. // Time Zone data value keys
  19. #define TIME_ZONE_REGKEY \
  20. L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Time Zones"
  21. #define TIME_ZONE_INFO_REGKEY \
  22. L"SYSTEM\\CurrentControlSet\\Control\\TimeZoneInformation"
  23. #define TIMEZONE_STANDARD_NAME \
  24. L"StandardName"
  25. #define TIME_ZONE_DISPLAYNAME_REGVAL L"Display"
  26. #define TIME_ZONE_STANDARDNAME_REGVAL L"Std"
  27. #define TIME_ZONE_DAYLIGHTNAME_REGVAL L"Dlt"
  28. #define TIME_ZONE_INDEX_REGVAL L"Index"
  29. #define TIME_ZONE_TZI_REGVAL L"TZI"
  30. #define TIME_ZONE_MAPINFO_REGVAL L"MapID"
  31. #define TZNAME_SIZE 32
  32. #define TZDISPLAYZ 500
  33. #define MAXKEYNAMELEN 100
  34. // stuff from registry goes in here
  35. // whole point of this re-ordered structure is
  36. // because registry stores the last 5 fields
  37. // together in hex, want to read them in all at once
  38. typedef struct tagTZINFO {
  39. struct tagTZINFO *next;
  40. WCHAR szDisplayName[TZDISPLAYZ];
  41. WCHAR szStandardName[TZNAME_SIZE];
  42. WCHAR szDaylightName[TZNAME_SIZE];
  43. LONG Index;
  44. LONG Bias;
  45. LONG StandardBias;
  46. LONG DaylightBias;
  47. SYSTEMTIME StandardDate;
  48. SYSTEMTIME DaylightDate;
  49. } TZINFO, NEAR *PTZINFO;
  50. class CSystemClock : public IDispatch
  51. {
  52. private:
  53. ULONG m_cRef;
  54. WCHAR *m_szTimeZoneOptionStrs;
  55. PTZINFO m_pTimeZoneArr;
  56. ULONG m_cNumTimeZones, m_uCurTimeZoneIdx;
  57. BOOL m_bSetAutoDaylightMode;
  58. BOOL m_bTimeZonePreset;
  59. HINSTANCE m_hInstance;
  60. WCHAR DefltZoneKeyValue[MAXKEYNAMELEN];
  61. //internal SET functions
  62. HRESULT set_TimeZone (BSTR bstrTimeZone);
  63. HRESULT set_Time (WORD wHour, WORD wMinute, WORD wSec);
  64. HRESULT set_Date (WORD wMonth, WORD wDay, WORD wYear);
  65. //Methods
  66. void GetTimeZoneInfo(BOOL fAutoDaylightSavings, PTZINFO ptZone);
  67. void SetAllowLocalTimeChange (BOOL fAutoDaylightSavings);
  68. BOOL SetTheTimezone (BOOL fAutoDaylightSavings, PTZINFO ptZone);
  69. HRESULT ReadZoneData (PTZINFO ptZone, HKEY hKey, LPCWSTR szKeyName);
  70. HRESULT InitSystemClock();
  71. int GetTimeZoneValStr();
  72. public:
  73. CSystemClock (HINSTANCE m_bhInstance);
  74. ~CSystemClock ();
  75. // IUnknown Interfaces
  76. STDMETHODIMP QueryInterface (REFIID riid, LPVOID* ppvObj);
  77. STDMETHODIMP_(ULONG) AddRef ();
  78. STDMETHODIMP_(ULONG) Release ();
  79. //IDispatch Interfaces
  80. STDMETHOD (GetTypeInfoCount) (UINT* pcInfo);
  81. STDMETHOD (GetTypeInfo) (UINT, LCID, ITypeInfo** );
  82. STDMETHOD (GetIDsOfNames) (REFIID, OLECHAR**, UINT, LCID, DISPID* );
  83. STDMETHOD (Invoke) (DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult, EXCEPINFO* pexcepinfo, UINT* puArgErr);
  84. };
  85. #endif