diff --git a/rtl/win/sysutils.pp b/rtl/win/sysutils.pp index 6ebcc63fc9..726b389fe2 100644 --- a/rtl/win/sysutils.pp +++ b/rtl/win/sysutils.pp @@ -917,6 +917,12 @@ begin end; +type + TGetTimeZoneInformationForYear = function(wYear: USHORT; lpDynamicTimeZoneInformation: PDynamicTimeZoneInformation; + var lpTimeZoneInformation: TTimeZoneInformation): BOOL;stdcall; +var + GetTimeZoneInformationForYear:TGetTimeZoneInformationForYear=nil; + function GetLocalTimeOffset(const DateTime: TDateTime; const InputIsUTC: Boolean; out Offset: Integer): Boolean; var Year: Integer; @@ -961,10 +967,11 @@ var DSTStart, DSTEnd: TDateTime; begin + if not Assigned(GetTimeZoneInformationForYear) then + Exit(False); Year := YearOf(DateTime); TZInfo := Default(TTimeZoneInformation); - // GetTimeZoneInformationForYear is supported only on Vista and newer - if not ((Win32MajorVersion>=6) and GetTimeZoneInformationForYear(Year, nil, TZInfo)) then + if not GetTimeZoneInformationForYear(Year, nil, TZInfo) then Exit(False); if (TZInfo.StandardDate.Month>0) and (TZInfo.DaylightDate.Month>0) then @@ -1590,6 +1597,9 @@ begin FindExInfoDefaults := FindExInfoStandard; // also searches SFNs. XP only. if (Win32MajorVersion>=6) and (Win32MinorVersion>=1) then FindFirstAdditionalFlags := FIND_FIRST_EX_LARGE_FETCH; // win7 and 2008R2+ + // GetTimeZoneInformationForYear is supported only on Vista and newer + if (kernel32dll<>0) and (Win32MajorVersion>=6) then + GetTimeZoneInformationForYear:=TGetTimeZoneInformationForYear(GetProcAddress(kernel32dll,'GetTimeZoneInformationForYear')); end; Function GetAppConfigDir(Global : Boolean) : String; diff --git a/rtl/win/wininc/redef.inc b/rtl/win/wininc/redef.inc index bbedbc315a..8ee799b7d9 100644 --- a/rtl/win/wininc/redef.inc +++ b/rtl/win/wininc/redef.inc @@ -623,8 +623,8 @@ function GetThreadPriorityBoost(hThread: THandle; var DisablePriorityBoost: Bool function GetThreadSelectorEntry(hThread: THandle; dwSelector: DWORD; var lpSelectorEntry: TLDTEntry): BOOL; external 'kernel32' name 'GetThreadSelectorEntry'; function GetThreadTimes(hThread: THandle; var lpCreationTime, lpExitTime, lpKernelTime, lpUserTime: TFileTime): BOOL; external 'kernel32' name 'GetThreadTimes'; function GetTimeZoneInformation(var lpTimeZoneInformation: TTimeZoneInformation): DWORD; external 'kernel32' name 'GetTimeZoneInformation'; -function GetTimeZoneInformationForYear(wYear: USHORT; lpDynamicTimeZoneInformation: PDynamicTimeZoneInformation; - var lpTimeZoneInformation: TTimeZoneInformation): BOOL; external 'kernel32' name 'GetTimeZoneInformationForYear'; +//function GetTimeZoneInformationForYear(wYear: USHORT; lpDynamicTimeZoneInformation: PDynamicTimeZoneInformation; +// var lpTimeZoneInformation: TTimeZoneInformation): BOOL; external 'kernel32' name 'GetTimeZoneInformationForYear'; //function GetTitleBarInfo(hwnd: HWND; var pti: TTitleBarInfo): BOOL;external 'user32' name 'GetTitleBarInfo'; function GetTokenInformation(TokenHandle: THandle; TokenInformationClass: TTokenInformationClass; TokenInformation: Pointer; TokenInformationLength: DWORD; var ReturnLength: DWORD): BOOL; external 'advapi32' name 'GetTokenInformation'; function GetUpdateRect(hWnd: HWND; var lpRect: TRect; bErase: BOOL): BOOL; external 'user32' name 'GetUpdateRect';