如何修改系统时间?(关于VB6.0)

来源:百度知道 编辑:UC知道 时间:2024/06/10 14:13:56
我是初学者,麻烦各位帮我回答一个简单的问题。
如何用VB6.0创建一个程序,当程序运行时修改系统日期,当按一个按钮关闭程序时恢复系统日期?
比如:现在系统时间为2007.8.26,当程序运行时系统时间为2008.08.08,当程序关闭时日期为2007.8.26。

Thank You

Private Declare Function SetSystemTime Lib "kernel32" (lpSystemTime As SYSTEMTIME) As Long

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 CurDate As SYSTEMTIME

Private Sub Form_Load()

Dim lpSystemTime As SYSTEMTIME, succ As Long
With CurDate
.wYear = Year(Date)
.wMonth = Month(Date)
.wDay = Day(Date)
.wHour = Hour(Time)
.wMinute = Minute(Time)
.wSecond = Second(Time)
.wMilliseconds = 0
End With

With lpSystemTime
.wYear = 2008
.wMonth = 8
.wDay = 8
.wHour = Hour(Time)
.wMinute = Minute(Time)
.wSecond = Second(Time)
.wMilliseconds = 0
End With

succ = SetSystemTime(lpSystemTime)