by Disk Junky (1 Submission)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Wed 28th February 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Sets the time on the local machine. Very usefull.
API Declarations
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type
Private Declare Function SetLocalTime Lib "kernel32.dll" (lpSystemTime As SystemTime) As Long
Public Sub SetNewTime(NewHour As Integer, NewMinute As Integer, NewSecond As Integer)
' Set the system time with Hours, Minutes, Seconds
Dim SetTime As SystemTime
Dim RetVal As Long
SetTime.wHour = NewHour
SetTime.wMinute = NewMinute
SetTime.wSecond = NewSecond
SetTime.wMilliseconds = 0
SetTime.wDay = Day(Date)
SetTime.wMonth = Month(Date)
SetTime.wYear = Year(Date)
' Set time and date.
RetVal = SetLocalTime(SetTime)
End Sub