
Updating PC Date/Time via WinAPI
Quote:
>Yes, you can. I don't have an API book here to tell you
how.
Thanks. Found the answer:
<--- CODE --->
Private Type SYSTEMTIME
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 SetSystemTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME) As Long
'
Public Sub SetDate()
Dim lpSystemTime As SYSTEMTIME
Dim datDate As Date
datDate = #1/19/2001 11:59:59 PM# 'Alter to a
Dlookup Statement
lpSystemTime.wYear = Format(datDate, "yyyy")
lpSystemTime.wMonth = Format(datDate, "mm")
lpSystemTime.wDay = Format(datDate, "dd")
lpSystemTime.wHour = Format(datDate, "hh")
lpSystemTime.wMinute = Format(datDate, "nn")
lpSystemTime.wSecond = Format(datDate, "ss")
lpSystemTime.wMilliseconds = 0
'set the new time
SetSystemTime lpSystemTime
End Sub
<--- END CODE --->