; #FUNCTION# ====================================================================================================================
; Name...........: _Date_Time_SetTimeZoneInformation
; Description ...: Sets the current time zone settings
; Syntax.........: _Date_Time_SetTimeZoneInformation($iBias, $sStdName, $tStdDate, $iStdBias, $sDayName, $tDayDate, $iDayBias)
; Parameters ....: $iBias - The current bias for local time translation on this computer. The bias is the difference in
; +minutes between Coordinated Universal Time (UTC) and local time. All translations between UTC and local time
; +use the following formula: UTC = local time + bias
; $sStdName - The description for standard time
; $tStdDate - A %tagSYSTEMTIME structure that contains a date and local time when the transition from
; +daylight saving time to standard time occurs.
; $iStdBias - The bias value to be used during local time translations that occur during standard time. This
; +value is added to the value of the Bias to form the bias used during standard time. In most time zones, this
; +value is zero.
; $sDayName - The description for daylight saving time
; $tDayDate - A %tagSYSTEMTIME structure that contains a date and local time when the transition from
; +standard time to daylight saving time occurs.
; $iDayBias - The bias value to be used during local time translation that occur during daylight saving time.
; +This value is added to the value of the Bias member to form the bias used during daylight saving time. In
; +most time zones this value is –60.
; Return values .: Success - True
; Failure - False
; Author ........: Paul Campbell (PaulIA)
; Modified.......: Gary Frost (gafrost)
; Remarks .......:
; Related .......: _Date_Time_GetTimeZoneInformation, $tagSYSTEMTIME
; Link ..........;
; Example .......; Yes
; ===============================================================================================================================
Func _Date_Time_SetTimeZoneInformation($iBias, $sStdName, $tStdDate, $iStdBias, $sDayName, $tDayDate, $iDayBias)
Local $hToken, $tStdName, $tDayName, $tZoneInfo, $aResult
$tStdName = _WinAPI_MultiByteToWideChar($sStdName)
$tDayName = _WinAPI_MultiByteToWideChar($sDayName)
$tZoneInfo = DllStructCreate($tagTIME_ZONE_INFORMATION)
DllStructSetData($tZoneInfo, "Bias", $iBias)
DllStructSetData($tZoneInfo, "StdName", DllStructGetData($tStdName, 1))
_MemMoveMemory(DllStructGetPtr($tStdDate), DllStructGetPtr($tZoneInfo, "StdDate"), DllStructGetSize($tStdDate))
DllStructSetData($tZoneInfo, "StdBias", $iStdBias)
DllStructSetData($tZoneInfo, "DayName", DllStructGetData($tDayName, 1))
_MemMoveMemory(DllStructGetPtr($tDayDate), DllStructGetPtr($tZoneInfo, "DayDate"), DllStructGetSize($tDayDate))
DllStructSetData($tZoneInfo, "DayBias", $iDayBias)
; Enable system time privileged mode
$hToken = _Security__OpenThreadTokenEx(BitOR($__DATECONSTANT_TOKEN_ADJUST_PRIVILEGES, $__DATECONSTANT_TOKEN_QUERY))
_WinAPI_Check("_Date_Time_SetSystemTimeAjustment:OpenThreadTokenEx", @error, @extended)
_Security__SetPrivilege($hToken, "SeSystemtimePrivilege", True)
_WinAPI_Check("_Date_Time_SetSystemTimeAjustment:SetPrivilege:Enable", @error, @extended)
; Set time zone information
$aResult = DllCall("Kernel32.dll", "int", "SetTimeZoneInformation", "ptr", DllStructGetPtr($tZoneInfo))
; Disable system time privileged mode
_Security__SetPrivilege($hToken, "SeSystemtimePrivilege", False)
_WinAPI_Check("_Date_Time_SetSystemTimeAdjustment:SetPrivilege:Disable", @error, @extended)
_WinAPI_CloseHandle($hToken)
Return SetError($aResult[0] = 0, 0, $aResult[0] <> 0)
EndFunc ;==>_Date_Time_SetTimeZoneInformation