as per the title, does anyone know how to Change the System Date/Time via VB.Net?
thanks in advance
Printable View
as per the title, does anyone know how to Change the System Date/Time via VB.Net?
thanks in advance
Found how to:
(if this is not the best way, please add)
Code:Private Structure SYSTEMTIME
Public year As Short
Public month As Short
Public dayOfWeek As Short
Public day As Short
Public hour As Short
Public minute As Short
Public second As Short
Public milliseconds As Short
End Structure
<DllImport("Kernel32.dll")> Private Shared Function SetLocalTime(ByRef time As SYSTEMTIME) As Boolean
End Function
Private Sub ChangeDate
Dim st As SYSTEMTIME
Dim NewDate As Date = "28-April-1978 22:30:00"
st.year = NewDate .Year
st.month = NewDate.Month
st.dayOfWeek = NewDate.DayOfWeek
st.day = NewDate.Day
st.hour = NewDate.Hour
st.minute = NewDate.Minute
st.second = NewDate.Second
st.milliseconds = NewDate.Millisecond
'Set the new time...
SetLocalTime(st)
End Sub