通过祥大唯C语言实现关机,有两种方式:
1 通过system函数,调用dos的关机命令。
通过stdlib.h中的
int system(char *cmd)
可以执行dos命令cmd。
dos下关机的命令为shutdown -s,于是嗲用
system("shutdown -s")
即可实仿型现关机 *** 作。
2 通过调用windows提供的api函数,来实现关谨培机:
void shut_down_windows(){
HANDLE hToken
TOKEN_PRIVILEGES tkp
// Get a token for this process.
if (!OpenProcessToken(GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
return( FALSE )
// Get the LUID for the shutdown privilege.
LookupPrivilegeValue(NULL, SE_SHUTDOWN_NAME,
&tkp.Privileges[0].Luid)
tkp.PrivilegeCount = 1 // one privilege to set
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED
// Get the shutdown privilege for this process.
AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
(PTOKEN_PRIVILEGES)NULL, 0)
if (GetLastError() != ERROR_SUCCESS)
return FALSE
// Shut down the system and force all applications to close.
if (!ExitWindowsEx(EWX_SHUTDOWN | EWX_FORCE,
SHTDN_REASON_MAJOR_OPERATINGSYSTEM |
SHTDN_REASON_MINOR_UPGRADE |
SHTDN_REASON_FLAG_PLANNED))
return FALSE
return TRUE
}
来自:http://wenku.baidu.com/view/3a3b5fec4afe04a1b071de7d.htmlForm1(主界面)
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Const TOKEN_ADJUST_PRIVILEGES = &H20
Const TOKEN_QUERY = &H8
Const SE_PRIVILEGE_ENABLED = &H2
Private Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const HELP_CONTENTS = &H3&
Const EWX_LOGOFF = 0 '注销
Const EWX_SHUTDOWN = 1 '待蠢衡高机
Const EWX_REBOOT = 2 '重新启动
Const EWX_WAIT = 16
Const EWX_FORCE = 4 '终拦顷止没有响应的带尺进程
Const EWX_POWEROFF = 8 '关闭电源
Const xStr As String = "0123456789"
'=========================================================================================================窗口在前
'Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
'Private Const HWND_TOPMOST&= -1
'Private Const SWP_NOSIZE&= &H1
'Private Const SWP_NOMOVE&= &H2
'===================================================================================================================
Dim WindowTop, WindowLeft
Public txt As Long
Private Sub Command1_Click() ''确定
If Command1.Caption = "设定" Then
Text1.Enabled = True
Text1.SetFocus
Command1.Caption = "确定"
Label1.Caption = "请输入关机时间:"
Label2.Caption = "如22时55分30秒关机则输入225530"
Exit Sub
ElseIf Command1.Caption = "确定" Then
If Len(Text1) <6 Then
Call sjcw
Text1 = ""
Text1.SetFocus
Else
b1 = Format(Mid(Text1, 1, 2), "00")
b2 = Format(Mid(Text1, 3, 2), "00")
b3 = Format(Mid(Text1, 5, 2), "00")
If b1 >23 Or b2 >59 Or b3 >59 Then
Call sjcw
Else
pdt = Text1 ''关机时间
Text1.Enabled = False
Command1.Caption = "修改"
Label1.Caption = "关机时间为:" &b1 &":" &b2 &":" &b3
Label2.Caption = "点击“启动”开启自动关机功能"
Command2.Enabled = True
Exit Sub
End If
End If
Else
Text1.Enabled = True
Text1.SetFocus
Command1.Caption = "确定"
Label1.Caption = "请输入关机时间:"
Label2.Caption = "如22时55分30秒关机则输入225530"
Exit Sub
End If
End Sub
Private Sub Command2_Click() ''启动
If Command2.Caption = "启动" Then
b1 = Format(Mid(Text1, 1, 2), "00")
b2 = Format(Mid(Text1, 3, 2), "00")
b3 = Format(Mid(Text1, 5, 2), "00")
If b1 >23 Or b2 >59 Or b3 >59 Then
Call sjcw
Else
Open App.Path + "\mrpdt.dat" For Output As #5 Len = 6
Cls
For i = 1 To 6
t = Mid(Val(Text1), i, 1)
tt = tt &t
Next i
tt = Format(tt, "000000")
Print #5, tt
Close #5
Timer1.Enabled = True
Command2.Caption = "停止"
Command1.Caption = "修改"
Label1.Caption = "关机时间为:" &b1 &":" &b2 &":" &b3
Label2.Caption = "点击“启动”开启自动关机功能"
Command1.Enabled = False
Text1.Enabled = False
Open App.Path + "\rjsz.dat" For Input As #1
Input #1, rjsz
Close #1
rjsz = Format(rjsz, "00000")
If Mid(rjsz, 2, 1) = 1 Then
Me.WindowState = 1 ''点击启动到托盘
End If
End If
Else
Timer1.Enabled = False
Command2.Caption = "启动"
Command1.Enabled = True
End If
End Sub
Private Sub Command3_Click() ''设置
Form2.Show
Form2.Top = Form1.Top
Form2.Left = Form1.Left + Form1.Width
End Sub
Private Sub Form_Load()
'=================================================================================================================
Dim hProcessHandle As Long
Dim hTokenHandle As Long
Dim tmpLuid As LUID
Dim tkpNew As TOKEN_PRIVILEGES
Dim tkpPrevious As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long
hProcessHandle = GetCurrentProcess()
OpenProcessToken hProcessHandle, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hTokenHandle
LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid
tkpNew.PrivilegeCount = 1
tkpNew.TheLuid = tmpLuid
tkpNew.Attributes = SE_PRIVILEGE_ENABLED
lBufferNeeded = 0
AdjustTokenPrivileges hTokenHandle, False, tkpNew, Len(tkpPrevious), tkpPrevious, lBufferNeeded
'================================================================================================================
'SetWindowPos Form1.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE '窗口在前
'================================================================================================================
If Dir(App.Path + "\rjsz.dat") <>"" Then
Open App.Path + "\rjsz.dat" For Input As #1
Input #1, rjsz
Close #1
rjsz = Format(rjsz, "00000")
If Dir(App.Path + "\mrpdt.dat") <>"" Then
If Mid(rjsz, 3, 1) = 1 Then
Open App.Path + "\mrpdt.dat" For Input As #2 Len = 5
Input #2, mrt
mrt = Format(mrt, "000000")
Text1 = mrt
a1 = Format(Mid(mrt, 1, 2), "00")
a2 = Format(Mid(mrt, 3, 2), "00")
a3 = Format(Mid(mrt, 5, 2), "00")
Label1.Caption = "关机时间为:" &a1 &":" &a2 &":" &a3
Label2.Caption = "点击“启动”开启自动关机功能"
Text1.Enabled = False
Command1.Caption = "修改"
Close #2
End If
End If
If Mid(rjsz, 1, 1) = 1 Then
Call Command2_Click ''开机自动启动
End If
End If
End Sub
Private Sub Label4_Click()
Call tuichu
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim lMsg As Single
lMsg = X / Screen.TwipsPerPixelX
Select Case lMsg
Case WM_LBUTTONDBLCLK '双击左键显示窗体,要改成其他的看模块里的定义
ShowWindow Me.hWnd, SW_RESTORE
Me.Top = (Screen.Height - Form1.Height) / 2
Me.Left = (Screen.Width - Form1.Width) / 2
Me.SetFocus
Case WM_RBUTTONUP '在托盘图标上点右键显示菜单
PopupMenu F00 '菜单名称为F00
End Select
End Sub
Private Sub Label5_Click()
Form3.Show
Form3.Top = Form1.Top
Form3.Left = Form1.Left - Form3.Width
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer) ''只能输入数字
KeyAscii = IIf(InStr(xStr &Chr(8), Chr(KeyAscii)), KeyAscii, 0)
End Sub
Function WindowStyle()
With nfIconData
.hWnd = Me.hWnd
.uID = Me.Icon
.uFlags = NIF_ICON Or NIF_MESSAGE Or NIF_TIP
.uCallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon.Handle
.szTip = Label7.Caption &vbNullChar
.cbSize = Len(nfIconData)
End With
Call Shell_NotifyIcon(NIM_ADD, nfIconData)
Me.Hide
End Function
Private Sub Form_Resize()
WindowTop = Me.Top
WindowLeft = Me.Left
If Me.WindowState = 1 Then
WindowStyle
End If
End Sub
Private Sub F01_Click()
ShowWindow Me.hWnd, SW_RESTORE
Me.Top = (Screen.Height - Form1.Height) / 2
Me.Left = (Screen.Width - Form1.Width) / 2
End Sub
Private Sub F02_Click()
Call tuichu
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) '关闭按钮
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End
End Sub
Function sjcw() ''数据错误
MsgBox "数据不合法,请重新输入!", vbOKOnly + vbCritical, "错误"
Text1 = ""
If Text1.Enabled = True Then
Text1.SetFocus
End If
End Function
Function tuichu()
ms = MsgBox("退出后自动关机功能将停用!" + Chr(13) + "确定退出?", vbOKCancel + vbExclamation + vbDefaultButton2, "提示")
If ms = vbCancel Then
Cancel = 1
Else
Call Shell_NotifyIcon(NIM_DELETE, nfIconData)
End
End If
End Function
Private Sub Timer1_Timer()
ntm = Format(Hour(Now), "00") &Format(Minute(Now), "00") &Format(Second(Now), "00")
If ntm = Text1 Then
Call PowerDown
End If
End Sub
Private Sub Timer2_Timer()
Label3.Caption = "现在时间:" &Now
If Dir(App.Path + "\rjsz.dat") <>"" Then
Open App.Path + "\rjsz.dat" For Input As #1 Len = 5
Input #1, rjsz
Close #1
rjsz = Format(rjsz, "00000")
If Mid(rjsz, 4, 1) = 1 And Command2.Caption = "停止" Then
txt = Mid(rjsz, 5, 1) ''提醒时间
NT1 = Format(Hour(Now), "00")
NT2 = Format(Minute(Now), "00")
NT3 = Format(Second(Now), "00")
GT1 = Format(Mid(Text1, 1, 2), "00")
GT2 = Format(Mid(Text1, 3, 2), "00")
GT3 = Format(Mid(Text1, 5, 2), "00")
nt = NT1 &NT2 &NT3
If GT2 - txt >= 0 Then
Gt = GT1 &Format((GT2 - txt), "00") &GT3
Else
If GT1 - 1 >= 0 Then
Gt = Format((GT1 - 1), "00") &Format((60 + GT2 - txt), "00") &GT3
Else
Gt = 23 &Format((60 + GT2 - txt), "00") &GT3
End If
End If
If Gt = nt Then
Form4.Show
End If
If GT3 - NT3 >= 0 Then '剩余时间
Ts = GT3 - NT3
If GT2 - NT2 >= 0 Then
Tm = GT2 - NT2
If GT1 - NT1 >= 0 Then
Th = GT1 - NT1
Else
Th = GT1 + 24 - NT1
End If
Else
If GT1 - NT1 - 1 >= 0 Then
Tm = GT2 + 60 - GT1
Th = GT1 - NT1 - 1
Else
Tm = GT2 + 60 - GT1
Th = 24 + GT1 - NT1 - 1
End If
End If
Else
If GT2 - NT2 - 1 >= 0 Then
Ts = GT3 + 60 - NT3
Tm = GT2 - NT2 - 1
If GT1 - NT1 >= 0 Then
Th = GT1 - NT1
Else
Th = GT1 + 24 - NT1
End If
Else
If GT1 - NT1 - 1 >= 0 Then
Ts = GT3 + 60 - NT3
Tm = GT2 + 60 - NT3 - 1
Th = GT1 - NT1 - 1
Else
Ts = GT3 + 60 - NT3
Tm = GT2 + 60 - NT2 - 1
Th = 24 + GT1 - NT1 - 1
End If
End If
End If
Label7.Visible = True
Label7.Caption = "关机倒计时:" &Th &"时" &Tm &"分" &Ts &"秒"
If Th = 0 And Tm <5 Then
Label7.ForeColor = vbRed
End If
End If
End If
End Sub
Function PowerDown()
ExitWindowsEx (EWX_SHUTDOWN Or EWX_FORCE Or EWX_POWEROFF), 0
Timer1.Enabled = False
End Function
Form2(设置)
Private Sub Command1_Click()
Dim v As Long
For i = 1 To 4
v = v &Check1(i - 1).Value
Next i
If v = 0 Then
Command1.Caption = "全清"
For i = 1 To 4
Check1(i - 1).Value = 1
Next i
Else
Command1.Caption = "全选"
For i = 1 To 4
Check1(i - 1).Value = 0
Next i
End If
End Sub
Private Sub Command2_Click()
'Dim c As Long, d As Long
Open App.Path + "\rjsz.dat" For Output As #4 Len = 5
Cls
For i = 1 To 4
c = Check1(i - 1).Value
cc = cc &c
Next i
d = Combo1.Text
cc = cc &d
Print #4, cc
Close #4
If Check1(0).Value = 1 Then '''开机自动启动
Call SetAutoRun(True)
Else
Call SetAutoRun(False)
End If
Unload Form2
End Sub
Private Sub Form_Load()
Dim s As Long
Combo1.AddItem 1
Combo1.AddItem 2
Combo1.AddItem 3
Combo1.AddItem 4
Combo1.AddItem 5
If Dir(App.Path + "\rjsz.dat") <>"" Then
Open App.Path + "\rjsz.dat" For Input As #3 Len = 5
Input #3, sss
sss = Format(sss, "00000")
For i = 1 To 4
Check1(i - 1).Value = Mid(sss, i, 1)
Next i
Combo1.Text = Mid(sss, 5, 1)
Close #3
End If
End Sub
Private Sub Timer1_Timer()
For i = 1 To 4
v = v &Check1(i - 1).Value
Next i
If v = 0 Then
Command1.Caption = "全选"
Else
Command1.Caption = "全清"
End If
End Sub
Form3(关于)
Private Sub Label13_Click()
Form2.Left = Form1.Left + Form1.Width
Form2.Top = Form1.Top
Form2.Show
End Sub
Form4(提示)
Private Sub Command1_Click()
Form4.Hide
End Sub
Private Sub Command2_Click()
MsgBox "你可回主界面重新" + Chr(13) + "开启自动关机功能!", vbOKOnly + vbInformation, "提示"
Form4.Hide
Form1.Show
End Sub
Private Sub Form_Load()
Label1.Caption = "还有" &Form1.txt &"分钟将关机!请做好保存工作。"
End Sub
把下面的代码,拷贝到记事本,另存为一个窗体文返陪件漏信蠢,试试看坦凳,错误不用管,只是图标问题,没有影响VERSION 5.00
Begin VB.Form Form1
BackColor = &H00FFC0C0&
BorderStyle = 1 'Fixed Single
Caption = "定时关机系统"
ClientHeight= 2205
ClientLeft = 45
ClientTop = 435
ClientWidth = 4470
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 2205
ScaleWidth = 4470
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
BackColor = &H00FFC0C0&
Caption = "修改任务(&M):"
Enabled = 0 'False
Height = 1695
Left= 1890
TabIndex= 2
Top = 120
Width = 2490
Begin VB.Timer Timer1
Interval= 1000
Left= 1890
Top = 435
End
Begin VB.CommandButton Command2
Caption = "设置(&S)"
Height = 495
Left= 1560
TabIndex= 7
Top = 1035
Width = 825
End
Begin VB.ComboBox Combo3
BackColor = &H00FFC0FF&
ForeColor = &H00FF0000&
Height = 300
Left= 855
Style = 2 'Dropdown List
TabIndex= 6
Top = 1230
Width = 615
End
Begin VB.ComboBox Combo2
BackColor = &H00FFC0FF&
ForeColor = &H00FF0000&
Height = 300
Left= 855
Style = 2 'Dropdown List
TabIndex= 5
Top = 750
Width = 615
End
Begin VB.ComboBox Combo1
BackColor = &H00FFC0FF&
ForeColor = &H00FF0000&
Height = 300
Left= 855
Style = 2 'Dropdown List
TabIndex= 3
Top = 285
Width = 975
End
Begin VB.Label Label4
AutoSize= -1 'True
BackStyle = 0 'Transparent
Caption = "分钟(&M):"
Height = 180
Left= 90
TabIndex= 9
Top = 1275
Width = 810
End
Begin VB.Label Label3
AutoSize= -1 'True
BackStyle = 0 'Transparent
Caption = "小时(&H):"
Height = 180
Left= 90
TabIndex= 8
Top = 795
Width = 810
End
Begin VB.Label Label2
AutoSize= -1 'True
BackStyle = 0 'Transparent
Caption = "星期(&W):"
Height = 180
Left= 90
TabIndex= 4
Top = 330
Width = 810
End
End
Begin VB.Frame Frame1
BackColor = &H00FFC0C0&
Caption = "任务列表(&L):"
Height = 1695
Left= 120
TabIndex= 0
Top = 120
Width = 1695
Begin VB.PictureBox Picture1
Enabled = 0 'False
Height = 1320
Left= 60
ScaleHeight = 1260
ScaleWidth = 1485
TabIndex= 10
Top = 255
Width = 1545
Begin VB.ListBox List1
BackColor = &H00FFC0FF&
ForeColor = &H00FF0000&
Height = 1320
Left= -30
Sorted = -1 'True
TabIndex= 11
Top = -30
Width = 1560
End
End
End
Begin VB.Label Label1
AutoSize= -1 'True
BackStyle = 0 'Transparent
Height = 180
Left= 390
TabIndex= 1
Top = 1920
Width = 90
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Declare Function GetCurrentProcess Lib "kernel32" () As Long
Private Declare Function OpenProcessToken Lib "advapi32" (ByVal ProcessHandle As Long, ByVal DesiredAccess As Long, TokenHandle As Long) As Long
Private Declare Function LookupPrivilegeValue Lib "advapi32" Alias "LookupPrivilegeValueA" (ByVal lpSystemName As String, ByVal lpName As String, lpLuid As LUID) As Long
Private Declare Function AdjustTokenPrivileges Lib "advapi32" (ByVal TokenHandle As Long, ByVal DisableAllPrivileges As Long, NewState As TOKEN_PRIVILEGES, ByVal BufferLength As Long, PreviousState As TOKEN_PRIVILEGES, ReturnLength As Long) As Long
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
Const TOKEN_ADJUST_PRIVILEGES = &H20
Const TOKEN_QUERY = &H8
Const SE_PRIVILEGE_ENABLED = &H2
Private Type LUID
UsedPart As Long
IgnoredForNowHigh32BitPart As Long
End Type
Private Type TOKEN_PRIVILEGES
PrivilegeCount As Long
TheLuid As LUID
Attributes As Long
End Type
Const HELP_CONTENTS = &H3&
Const EWX_WAIT = 16
Const EWX_REBOOT = 2 '重起
Const EWX_LOGOFF = 0 '注销
Const EWX_FORCE = 4 '终止没有响应的进程
Const EWX_SHUTDOWN = 8 '关闭电源
Private Sub Command2_Click()
Dim s As String
Dim i As Integer
Dim A(1 To 7) As String
If Len(Dir(App.Path &"\set.ini")) = 0 Then '还没有该文件
Open App.Path &"\set.ini" For Output As #1
Print #1, Combo1.ListIndex + 1 &" " &Combo1.Text &" " &Combo2.Text &":" &Combo3.Text
Close #1
Else
Open App.Path &"\set.ini" For Input As #1
While Not EOF(1)
Line Input #1, s
A(Val(Split(s, " ")(0))) = s
Wend
Close #1
A(Combo1.ListIndex + 1) = Combo1.ListIndex + 1 &" " &Combo1.Text &" " &Combo2.Text &":" &Combo3.Text
Open App.Path &"\set.ini" For Output As #1
For i = 1 To 7
If A(i) <>"" Then
Print #1, A(i)
End If
Next
Close #1
End If
LoadSet
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim hProcessHandle As Long
Dim hTokenHandle As Long
Dim tmpLuid As LUID
Dim tkpNew As TOKEN_PRIVILEGES
Dim tkpPrevious As TOKEN_PRIVILEGES
Dim lBufferNeeded As Long
'获取当前进程的一个伪句柄
hProcessHandle = GetCurrentProcess()
OpenProcessToken hProcessHandle, TOKEN_ADJUST_PRIVILEGES Or TOKEN_QUERY, hTokenHandle
LookupPrivilegeValue "", "SeShutdownPrivilege", tmpLuid
tkpNew.PrivilegeCount = 1
tkpNew.TheLuid = tmpLuid
tkpNew.Attributes = SE_PRIVILEGE_ENABLED
lBufferNeeded = 0
'允许当前应用程序有关闭 *** 作系统的权限
AdjustTokenPrivileges hTokenHandle, False, tkpNew, Len(tkpPrevious), tkpPrevious, lBufferNeeded
Combo1.ListIndex = 0
For i = 0 To 23
Combo2.AddItem i
Next
Combo2.ListIndex = 0
For i = 0 To 59
Combo3.AddItem i
Next
Combo3.ListIndex = 0
LoadSet
Me.Move Screen.Width - Me.Width, Screen.Height - Me.Height - 400
End Sub
Sub LoadSet()
Dim s As String
Dim w
w = Split("日,一,二,三,四,五,六", ",")
List1.Clear
If Dir(App.Path &"\set.ini") <>"" Then
Open App.Path &"\set.ini" For Input As #1
While Not EOF(1)
Line Input #1, s
List1.AddItem s
Wend
Close #1
End If
List1.ListIndex = IIf(Weekday(Date) = 1, 6, Weekday(Date) - 2)
Label1.Caption = "当前时间 " &Time &" " &Format(Date, "YYYY年MM月DD日") &" 星期" &w(Weekday(Date) - 1)
End Sub
Private Sub Frame1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static But As Integer
If Button = 1 Then
Frame2.Enabled = False
Else
But = But + 1
If But Mod 5 = 0 Then
Frame2.Enabled = True
But = 0
End If
End If
End Sub
Private Sub Label2_Click()
Combo1.SetFocus
End Sub
Private Sub Label3_Click()
Combo2.SetFocus
End Sub
Private Sub Label4_Click()
Combo3.SetFocus
End Sub
Private Sub Timer1_Timer()
'显示当前系统时间
Dim w
w = Split("日,一,二,三,四,五,六", ",")
Label1.Caption = "当前时间 " &Time &" " &Format(Date, "YYYY年MM月DD日") &" 星期" &w(Weekday(Date) - 1)
Dim H As Integer, M As Integer
H = Split(Split(List1.Text, " ")(2), ":")(0)
M = Split(Split(List1.Text, " ")(2), ":")(1)
If H = Hour(Time) And M = Minute(Time) Then
Label1.Caption = "现在关机"
End If
End Sub
另外:
Set.ini文件的内容如下
1 星期一 7:0
2 星期二 17:45
3 星期三 17:45
4 星期四 17:45
5 星期五 21:45
6 星期六 21:45
7 星期日 8:20
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)