如何修改系统时间?(关于VB6.0)
我是初学者,麻烦各位帮我回答一个简单的问题。如何用VB6.0创建一个程序,当程序运行时修改系统日期,当按一个按钮关闭程序时恢复系统日期?比如:现在系统时间为2007.8....
我是初学者,麻烦各位帮我回答一个简单的问题。
如何用VB6.0创建一个程序,当程序运行时修改系统日期,当按一个按钮关闭程序时恢复系统日期?
比如:现在系统时间为2007.8.26,当程序运行时系统时间为2008.08.08,当程序关闭时日期为2007.8.26。
Thank You 展开
如何用VB6.0创建一个程序,当程序运行时修改系统日期,当按一个按钮关闭程序时恢复系统日期?
比如:现在系统时间为2007.8.26,当程序运行时系统时间为2008.08.08,当程序关闭时日期为2007.8.26。
Thank You 展开
5个回答
展开全部
Dim d As Date
Private Sub Form_Load()
d = Date
Shell "cmd /c date 2008-08-08" '(替换成你需要的日期)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Shell "cmd /c date " & d, vbHide
End Sub
Private Sub Form_Load()
d = Date
Shell "cmd /c date 2008-08-08" '(替换成你需要的日期)
End Sub
Private Sub Form_Unload(Cancel As Integer)
Shell "cmd /c date " & d, vbHide
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Form_Load添加:
shell "cmd /c date 2008-08-08",vbhide
Form_Unload添加:
shell "cmd /c date 2007-08-26",vbhide
shell "cmd /c date 2008-08-08",vbhide
Form_Unload添加:
shell "cmd /c date 2007-08-26",vbhide
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
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)
If succ = 0 Then
MsgBox "修改时间失败!", vbCritical + vbOKOnly, "失败"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim succ As Long
succ = SetSystemTime(CurDate)
If succ = 0 Then
MsgBox "修改时间失败!", vbCritical + vbOKOnly, "失败"
End If
End Sub
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)
If succ = 0 Then
MsgBox "修改时间失败!", vbCritical + vbOKOnly, "失败"
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim succ As Long
succ = SetSystemTime(CurDate)
If succ = 0 Then
MsgBox "修改时间失败!", vbCritical + vbOKOnly, "失败"
End If
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
very good!!!
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
受教了 我今天才知道DATE的用法
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询