📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "获取和设置系统时间"
ClientHeight = 2250
ClientLeft = 60
ClientTop = 345
ClientWidth = 4020
LinkTopic = "Form1"
ScaleHeight = 2250
ScaleWidth = 4020
StartUpPosition = 3 'Windows Default
Begin VB.Label Label2
Height = 495
Left = 240
TabIndex = 1
Top = 960
Width = 3615
End
Begin VB.Label Label1
Height = 375
Left = 240
TabIndex = 0
Top = 240
Width = 3615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
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 Sub GetLocalTime Lib "kernel32" (lpSystemTime As SYSTEMTIME)
Private Declare Function SetLocalTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME) _
As Long
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_Load()
Dim str_DateTime As String
Dim DateTime As SYSTEMTIME
GetLocalTime DateTime
str_DateTime = Str(DateTime.wYear) + "/" + Str(DateTime.wMonth) + "/" + _
Str(DateTime.wDay) + " " + Str(DateTime.wHour) + ":" + _
Str(DateTime.wMinute) + ":" + Str(DateTime.wSecond) + "." + _
Str(DateTime.wMilliseconds) + Chr(13)
Label1.Caption = "现在的系统时间:" & str_DateTime
DateTime.wYear = DateTime.wYear - 1
SetLocalTime DateTime
Sleep (1000)
GetLocalTime DateTime
str_DateTime = Str(DateTime.wYear) + "/" + Str(DateTime.wMonth) + "/" + _
Str(DateTime.wDay) + " " + Str(DateTime.wHour) + ":" + _
Str(DateTime.wMinute) + ":" + Str(DateTime.wSecond) + "." + _
Str(DateTime.wMilliseconds)
Label2.Caption = "设置后的系统时间:" & str_DateTime
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -